Fixed
Status Update
Comments
yr...@google.com <yr...@google.com> #2
Here's a really detailed StackOverflow answer that seems to point out some things to look at in relation to this behaviour:
http://stackoverflow.com/a/14293528/238753
gg...@gmail.com <gg...@gmail.com> #3
Thank you for your feedback. We assure you that we are doing our best to address the issue reported, however our product team has shifted work priority that doesn't include this issue. For now, we will be closing the issue as won't fix obsolete. If this issue currently still exists, we request that you log a new issue along with latest bug report here https://goo.gl/TbMiIO .
jp...@google.com <jp...@google.com> #4
Tested and confirmed that this bug affects Android 4.4 - 5.1 but was fixed in Android 6.0.
I've attached an updated sample project since the original one needed some tweaks to get it building.
I've attached an updated sample project since the original one needed some tweaks to get it building.
jm...@google.com <jm...@google.com> #5
I've tried to use the sample project that comes with ButterKnife sources.
https://github.com/JakeWharton/butterknife/tree/master/sample
I've updated its build.gradle to match the specified configuration:
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
minSdkVersion 19
targetSdkVersion 25
jackOptions {
enabled true
}
buildToolsVersion = '25.0.1'
ButterKnife 8.4
But I could not reproduce the issue, gradle clean assemble is successful on my side, and all source files seems generated by ap.
Could you give us on stacktrace and ideally a sample project that reproduces you case?
Thanks.
I've updated its build.gradle to match the specified configuration:
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
minSdkVersion 19
targetSdkVersion 25
jackOptions {
enabled true
}
buildToolsVersion = '25.0.1'
ButterKnife 8.4
But I could not reproduce the issue, gradle clean assemble is successful on my side, and all source files seems generated by ap.
Could you give us on stacktrace and ideally a sample project that reproduces you case?
Thanks.
jm...@google.com <jm...@google.com> #6
Actually, I don't get an NPE, but indeed, if I manually rm build/generated/source/apt/, files are not regenerated, even if in modify some source files. If I make a clean, they are.
Without Jack enabled, files are generated again after touching the same source files.
So issue seems to be reproduced after all.
Without Jack enabled, files are generated again after touching the same source files.
So issue seems to be reproduced after all.
jm...@google.com <jm...@google.com> #7
However I cannot reproduce the case if I don't delete the directory manually.
My scenario with the mentioned sample project is:
- gradle clean assemble
- edit a file (e.g. A.java) by adding/modifying a line
- gradle assemble
-check files timestamps: the generated sources that correspond to the file I've modifed (here A_ViewBinding.java, and subclasses *_ViewBindings of subclasses of A) are updated. If I modify a leaf class such as H.java, only H_ViewBinding.java is updated. When Jack is disabled, all classes seems regenerated everytime.
So if there's an issue with incremental compilation with Jack and annotation processor, I couldn't pinpoint it with my sample code, because I guess that manually deleting the "apt" directory is not your use case.
If you could provide a sample project and procedure that can reproduce the issue, telling which file is not regenerated, whereas it should have been, it would be greatly appreciated.
Thanks.
My scenario with the mentioned sample project is:
- gradle clean assemble
- edit a file (e.g. A.java) by adding/modifying a line
- gradle assemble
-check files timestamps: the generated sources that correspond to the file I've modifed (here A_ViewBinding.java, and subclasses *_ViewBindings of subclasses of A) are updated. If I modify a leaf class such as H.java, only H_ViewBinding.java is updated. When Jack is disabled, all classes seems regenerated everytime.
So if there's an issue with incremental compilation with Jack and annotation processor, I couldn't pinpoint it with my sample code, because I guess that manually deleting the "apt" directory is not your use case.
If you could provide a sample project and procedure that can reproduce the issue, telling which file is not regenerated, whereas it should have been, it would be greatly appreciated.
Thanks.
gg...@gmail.com <gg...@gmail.com> #8
After an hour of experiment, I found how to reproduce this BUG:
1, In the example, there is a class A and an MainActivity
2, modify the class A, and then rerun the app, NPE will occur
3, modify the MainActivity, rerun the app, NPE will disappear
There is sample code(a android module) and stack information in the attachment. My English is not good, I hope you can understand.
AndroidStudio version:
Android Studio 2.2.3
Build #AI-145.3537739, built on December 2, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
gradle version:2.14.1
gradle build tool version: 'com.android.tools.build:gradle:2.2.3'
SystemOS: macOS 10.12.2, if needed.
1, In the example, there is a class A and an MainActivity
2, modify the class A, and then rerun the app, NPE will occur
3, modify the MainActivity, rerun the app, NPE will disappear
There is sample code(a android module) and stack information in the attachment. My English is not good, I hope you can understand.
AndroidStudio version:
Android Studio 2.2.3
Build #AI-145.3537739, built on December 2, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
gradle version:2.14.1
gradle build tool version: 'com.android.tools.build:gradle:2.2.3'
SystemOS: macOS 10.12.2, if needed.
gg...@gmail.com <gg...@gmail.com> #9
When NPE occur, MainAcitivty_ViewBinding.java wasn't updated, as #6 said.
Also, in that case I check the classes.dex file using ClassyShark, there isn't MainAcitivty_ViewBinding.class too.It should be generated.
Also, in that case I check the classes.dex file using ClassyShark, there isn't MainAcitivty_ViewBinding.class too.It should be generated.
ga...@google.com <ga...@google.com> #10
[Comment deleted]
ga...@google.com <ga...@google.com> #11
@ggchaifeng I am unable to reproduce NPE with your sample project. Can you please try with Android Gradle plugin 2.3.0-beta2 (it requires Gradle 3.3, so please update gradle/wrapper/gradle-wrapper.properties).
Also, run Jack in process by specifying android.defaultConfig.jackOptions.jackInProcess = true in your build.gradle file (this is necessary as ButterKnife assumes classes from rt.jar are in the classpath, which is not the case when running Jack out of process).
Jean-Marie, with 2.3.0-beta2, my build/generated/source/apt dir gets regenerated if I delete it manually.
Also, run Jack in process by specifying android.defaultConfig.jackOptions.jackInProcess = true in your build.gradle file (this is necessary as ButterKnife assumes classes from rt.jar are in the classpath, which is not the case when running Jack out of process).
Jean-Marie, with 2.3.0-beta2, my build/generated/source/apt dir gets regenerated if I delete it manually.
jm...@google.com <jm...@google.com> #12
I couldn't reproduce it directly either with the attached sample, because some things were missing (buildscript classpath, ...), so I rebuilt one from scratch with the project wizard and modified it for it to have the same settings as the provided sample project (see attachement).
Also, the stacktrace.txt file contains a correct build log by Gradle, I don't see any error in it.
Is the NPException occuring at runtime? If so, I have one as well in my logcat, does yours look like:
$ adb shell am start -n "com.android.jack.myapplication/com.android.jack.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Waiting for process to come online
Connected to process 2776 on device emulator-5554
Connected to process 3337 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.android.jack.myapplication-2/lib/x86_64
W/art: Class android.support.v4.app.FragmentManagerImpl failed lock verification and will run slower.
W/art: Common causes for lock verification issues are non-optimized dex code
W/art: and incorrect proguard optimizations.
W/art: Class android.support.v4.util.LruCache failed lock verification and will run slower.
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.jack.myapplication, PID: 3337
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.jack.myapplication/com.android.jack.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at com.android.jack.myapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
It seems to be an issue with the getText() method called on the button, annotated with @BindView.
@gavra, I'll try with 2.3.0-beta2 to see if it changes something.
Also, the stacktrace.txt file contains a correct build log by Gradle, I don't see any error in it.
Is the NPException occuring at runtime? If so, I have one as well in my logcat, does yours look like:
$ adb shell am start -n "com.android.jack.myapplication/com.android.jack.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Waiting for process to come online
Connected to process 2776 on device emulator-5554
Connected to process 3337 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.android.jack.myapplication-2/lib/x86_64
W/art: Class android.support.v4.app.FragmentManagerImpl failed lock verification and will run slower.
W/art: Common causes for lock verification issues are non-optimized dex code
W/art: and incorrect proguard optimizations.
W/art: Class android.support.v4.util.LruCache failed lock verification and will run slower.
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.jack.myapplication, PID: 3337
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.jack.myapplication/com.android.jack.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at com.android.jack.myapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
It seems to be an issue with the getText() method called on the button, annotated with @BindView.
@gavra, I'll try with 2.3.0-beta2 to see if it changes something.
jm...@google.com <jm...@google.com> #13
I've updated the Gradle plugin from 2.2.3 to 2.3.0-beta2 (and Gradle wrapper from 2.14.1 to 3.3), and it seems to work now.
I've modified the 'A' class a couple of times and the app launches gracefully, whereas it works only on a clean build with the previous version of plugin.
I've modified the 'A' class a couple of times and the app launches gracefully, whereas it works only on a clean build with the previous version of plugin.
gg...@gmail.com <gg...@gmail.com> #14
All as @Jean-Marie said.
With Gradle plugin 2.3.0-beta2 and Gradle wrapper 3.3, it works well.
With Gradle plugin 2.3.0-beta2 and Gradle wrapper 3.3, it works well.
Description
You're compiling with SDK:
--What OS you are building on
--Build Tools version (ex: 21.1.1):
--Android Gradle Plugin Version (ex: 1.0.0):
--Tested Android Version (ex: API 21 or 5.0.0 (Lollipop):
--If the bug occurs during compilation run your compilation process with
build logs enabled ("gradle --debug ..." or "java -jar
<buildToolsPath>/jack.jar --verbose debug ...")
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 25
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
STEPS TO REPRODUCE:
1.using butterknife(v8.4) in a application.
2.use java8 with Jack compiler.
3.sometimes Jack didn't generate butterknife sources.