You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a compile time error: "error: attribute value must be constant" on the "R.id.content_frame". This occurs both using Android Studio and latest gradle plugin builds.
It's not rename-safe or compile-safe (kind of). If you open the layout XML for this and do an IDE-backed rename operation it will not catch this string and update it. It also means you can (technically) compile the above code if there is no content_frame ID that exists. Now the compilation will eventually fail because the generated code will become invalid.
It's hard to know what R class to reference in the generated code, especially when you take into consideration the fact that you can use references to IDs that exist in libraries that you are referencing.
It forces us to have defaults for both the value and name properties on each annotation which means you can write @InjectView Foo foo and Butter Knife will have to fail the builder rather than javac.
Because of these facts, I have chosen not to support library projects.
One way that this could potentially be solved is to use a Gradle plugin rather than an annotation processor. I don't have the time to explore something like that for a few months though.
androidmalin, VolleyCN, caofengbin, fantasy1022, zlsa and 3 morezhengjun2002, androidovshchik, jalcine, ivanshchitov, DylanMay and 17 moreqq897425998 and vipulyaara
Jake, is there any way to support library projects in the future? I love Butterknife in my other projects, but I am currently working on one that uses a shared "library" codebase to make three apps that mostly do style and resource overrides. Having Butterknife supporting the library project would be amazing.
Aw. I would love to be using this for a library module I am working on for my company. The library serves as the base application project with all of the shared code between most of the apps my company makes.
The README instructions are somewhat misleading, the Gradle plugin for library projects only create a seperate R2 class. I believe you still need to include the Dagger compiler too as well right?
Activity
JakeWharton commentedon Feb 12, 2014
Yes this is not supported. This is a tradeoff between ease-of-use and what I tolerate as a sane API.
The only way to accomplish something like this is to allow string values like this:
The downside's to this are:
content_frame
ID that exists. Now the compilation will eventually fail because the generated code will become invalid.R
class to reference in the generated code, especially when you take into consideration the fact that you can use references to IDs that exist in libraries that you are referencing.value
andname
properties on each annotation which means you can write@InjectView Foo foo
and Butter Knife will have to fail the builder rather thanjavac
.Because of these facts, I have chosen not to support library projects.
One way that this could potentially be solved is to use a Gradle plugin rather than an annotation processor. I don't have the time to explore something like that for a few months though.
Limitin commentedon Aug 27, 2015
Jake, is there any way to support library projects in the future? I love Butterknife in my other projects, but I am currently working on one that uses a shared "library" codebase to make three apps that mostly do style and resource overrides. Having Butterknife supporting the library project would be amazing.
ponsuyambu commentedon Oct 7, 2015
Jake, Shall we expect any improvements on this?
JakeWharton commentedon Oct 7, 2015
No. It's unlikely to ever be supported.
On Wed, Oct 7, 2015 at 2:37 PM Ponsuyambu Velladurai <
notifications@github.com> wrote:
Limitin commentedon Oct 7, 2015
Aw. I would love to be using this for a library module I am working on for my company. The library serves as the base application project with all of the shared code between most of the apps my company makes.
steffandroid commentedon Oct 7, 2015
As Butterknife won't support this, the next best option is probably Butterfork.
kongsonida commentedon Dec 2, 2015
The lib version 7.0.1 is not support @InjectView(name = "content_frame")
What should we do ?
peacepassion commentedon Jun 3, 2016
Butterfork is a solution. But I found another solution which used more easier. Ref ButterCookie.
JakeWharton commentedon Jul 13, 2016
That isn't enough information to be an actionable bug report.
On Tue, Jul 12, 2016 at 11:19 PM liuli notifications@github.com wrote:
rogerhu commentedon Jul 18, 2016
The README instructions are somewhat misleading, the Gradle plugin for library projects only create a seperate R2 class. I believe you still need to include the Dagger compiler too as well right?
https://github.com/JakeWharton/butterknife/blob/master/sample/library/build.gradle
6 remaining items