Fixed
Status Update
Comments
uc...@google.com <uc...@google.com> #2
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #3
Hi Liran, thanks for filling a bug report.
1) Does this happen when running the application, or when running the tests?
2) Can you please upload the application APK (and test one if it is relevant)? Alternatively, a list of classes in all dex files would be enough.
1) Does this happen when running the application, or when running the tests?
2) Can you please upload the application APK (and test one if it is relevant)? Alternatively, a list of classes in all dex files would be enough.
lb...@gmail.com <lb...@gmail.com> #4
@3
1. Running the app. We don't have unit testing, as we have a tiny company and focus on the minimal things we can to work well on the project.
2. Yes, but only via private email (not public here), because this is closed sourced app, which is from the office.
Do note, that the issue has occurred on Android 4.4 , but not on later versions.
1. Running the app. We don't have unit testing, as we have a tiny company and focus on the minimal things we can to work well on the project.
2. Yes, but only via private email (not public here), because this is closed sourced app, which is from the office.
Do note, that the issue has occurred on Android 4.4 , but not on later versions.
ga...@google.com <ga...@google.com> #5
Thanks, please send them to gavra@google.com.
lb...@gmail.com <lb...@gmail.com> #6
@5 OK sent.
Also wrote the steps needed.
Also wrote the steps needed.
ga...@google.com <ga...@google.com> #7
Issue is due not tracing classes annotated with runtime visible annotations. After examining logcat, annotation that was in the main classes.dex, was used to annotate class in classes3.dex, which led to:
Class resolved by unexpected DEX: Lcom/AmazonWebService;(0x9d03f7c8):0x8a7de000 ref [Lcom/vrest/HttpMethod;] Lcom/vrest/HttpMethod;(0x9d03f7c8):0x8bc12000
W/dalvikvm( 3781): (Lcom/AmazonWebService; had used a different Lcom/vrest/HttpMethod; during pre-verification)
Liran has confirmed that adding explicit keep rule for com/AmazonWebService fixes the issue.
Class resolved by unexpected DEX: Lcom/AmazonWebService;(0x9d03f7c8):0x8a7de000 ref [Lcom/vrest/HttpMethod;] Lcom/vrest/HttpMethod;(0x9d03f7c8):0x8bc12000
W/dalvikvm( 3781): (Lcom/AmazonWebService; had used a different Lcom/vrest/HttpMethod; during pre-verification)
Liran has confirmed that adding explicit keep rule for com/AmazonWebService fixes the issue.
lb...@gmail.com <lb...@gmail.com> #8
@7 I don't understand.
You mean that the gradle plugin decided to remove the annotation or its classes for some reason?
You mean that the gradle plugin decided to remove the annotation or its classes for some reason?
ga...@google.com <ga...@google.com> #9
For more details, please see https://issuetracker.google.com/37008250 .
Long story short, if there is an runtime visible annotation that is in the main dex, all classes annotated with it should be in the main dex as well. From our conversation, it seems that AmazonWebService class is annotated with a class that references HttpMethod, which could be the cause of the issue.
To answer your question in #8, the plugin is not removing any classes, they are all in the APK, but AmazonWebService has to be in classes.dex, which is not currently the case, and that causes issue.
Long story short, if there is an runtime visible annotation that is in the main dex, all classes annotated with it should be in the main dex as well. From our conversation, it seems that AmazonWebService class is annotated with a class that references HttpMethod, which could be the cause of the issue.
To answer your question in #8, the plugin is not removing any classes, they are all in the APK, but AmazonWebService has to be in classes.dex, which is not currently the case, and that causes issue.
ga...@google.com <ga...@google.com> #10
I've attached project that reproduces the issue when run on API 19. The issue is that annotation has an Enum reference, and both are in the main dex file, while the annotated class, Data, is in classes2.dex. Switching D8 main dex list, by adding to gradle.properties
android.enableD8MainDexList=false
produces a working APK.
android.enableD8MainDexList=false
produces a working APK.
ap...@google.com <ap...@google.com> #11
Project: r8
Branch: master
commit ff562da903acc163f6d1f8c133618d20ecb5e454
Author: Ivan Gavrilovic <gavra@google.com>
Date: Tue Mar 06 15:45:33 2018
Analyze field and method annotations for main dex list
Analyze annotations on fields and methods, in addion to
ones on the class. Classes containing any annotation
that references an enum should be in the main dex,
as otherwise reflection APIs e.g.
Method.getDeclaredAnnotations() cause runtime failures
on API 19 and below.
Test: updated multidex002 test
BUG=73800636
Change-Id: Ie56da36056b80ed1273b07bdf293046b39fc4126
M src/main/java/com/android/tools/r8/graph/DexClass.java
M src/main/java/com/android/tools/r8/shaking/MainDexListBuilder.java
A src/test/examples/multidex002/AnnotatedDirectMethod.java
A src/test/examples/multidex002/AnnotatedInstanceField.java
A src/test/examples/multidex002/AnnotatedMethodParameter.java
A src/test/examples/multidex002/AnnotatedNotKept.java
A src/test/examples/multidex002/AnnotatedStaticField.java
A src/test/examples/multidex002/AnnotatedVirtualMethod.java
A src/test/examples/multidex002/AnnotationWithEnum3.java
A src/test/examples/multidex002/AnnotationWithoutEnum.java
M src/test/examples/multidex002/ref-list-1.txt
https://r8-review.googlesource.com/17660
Branch: master
commit ff562da903acc163f6d1f8c133618d20ecb5e454
Author: Ivan Gavrilovic <gavra@google.com>
Date: Tue Mar 06 15:45:33 2018
Analyze field and method annotations for main dex list
Analyze annotations on fields and methods, in addion to
ones on the class. Classes containing any annotation
that references an enum should be in the main dex,
as otherwise reflection APIs e.g.
Method.getDeclaredAnnotations() cause runtime failures
on API 19 and below.
Test: updated multidex002 test
BUG=73800636
Change-Id: Ie56da36056b80ed1273b07bdf293046b39fc4126
M src/main/java/com/android/tools/r8/graph/DexClass.java
M src/main/java/com/android/tools/r8/shaking/MainDexListBuilder.java
A src/test/examples/multidex002/AnnotatedDirectMethod.java
A src/test/examples/multidex002/AnnotatedInstanceField.java
A src/test/examples/multidex002/AnnotatedMethodParameter.java
A src/test/examples/multidex002/AnnotatedNotKept.java
A src/test/examples/multidex002/AnnotatedStaticField.java
A src/test/examples/multidex002/AnnotatedVirtualMethod.java
A src/test/examples/multidex002/AnnotationWithEnum3.java
A src/test/examples/multidex002/AnnotationWithoutEnum.java
M src/test/examples/multidex002/ref-list-1.txt
ga...@google.com <ga...@google.com> #12
Merged in studio-3.1-release under ag/I8c2235710c6725a126b2730c7338b2d6241f3698.
lb...@gmail.com <lb...@gmail.com> #13
@12 Which version of 3.2 ?
ga...@google.com <ga...@google.com> #14
It should be 3.2.0-alpha07.
Description
Select File > Project Structure, click Project, and then locate Gradle version.
4.5
Android Plugin Version:
On the same page as the Gradle version, locate Android Plugin Version.
3.2.0-alpha04
Module Compile Sdk Version:
From the above page, select your module in the left pane and locate Compile Sdk Version.
27
Module Build Tools Version:
From the above page, locate Build Tools Version.
27.0.3
Android SDK Tools version:
Select Tools > Android > SDK Manager, click SDK Tools, and then locate Android SDK Tools
26.1.1
The bug:
We have a large project, that uses a lot of dependencies. Some are within the project itself (modules). One of them offers to use annotations for Internet-related operations.
Thing is, using the above gradle version, on Android 4.4 (maybe below too, but not on Android 5.0), it crashes as soon as it gets to the call of the function "method.getAnnotation()".
The only relevant log is:
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at java.lang.reflect.Method.getAnnotation(Native Method)
at java.lang.reflect.Method.getAnnotation(Method.java:266)