Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting into superclass when only subclass is modified. #440

Closed
lhunath opened this issue Feb 9, 2016 · 4 comments
Closed

Injecting into superclass when only subclass is modified. #440

lhunath opened this issue Feb 9, 2016 · 4 comments

Comments

@lhunath
Copy link

lhunath commented Feb 9, 2016

Given a class hierarchy like so:

class A { @Bind(R.id.a) View viewA; { ButterKnife.inject(this) } }

class B extends A { @Bind(R.id.b) View viewB; }

Where A and B exist in their own file, A.java and B.java, when you modify B.java without modifying A.java, you end up with viewA being null at runtime.

I use the following ANT build script to ensure all classes that include @Bind annotations are included for each build. This is not ideal but avoids the issue.

<project basedir=".">
    <description>
        Fix ButterKnife bug caused by the compiler not including unmodified @Bind classes.
    </description>

    <target name="prebuild" description="Ensure the right source files are added to the build">
        <touch>
            <fileset dir="../source/java">
                <contains text="@Bind" />
            </fileset>
        </touch>
    </target>
</project>

I'm not sure if a bug exists for this issue already; but it's likely related to #362

@tasomaniac
Copy link

I am just curious. When you do a clean build, does it work or is it always null?

@lhunath
Copy link
Author

lhunath commented Feb 11, 2016

Works just fine from a clean build. The issue only happens when the build is done using only the subclass.

Modifying both the subclass and the superclass files also doesn't trigger this bug.

@YiiGuxing
Copy link

don't use 'com.android.tools.build:gradle:2.0-xxx'.
#438

@JakeWharton
Copy link
Owner

This is a dupe of #31. Maybe we can write out superclass details into a non-Java file to be read across invocations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants