Fixed
Status Update
Comments
uc...@google.com <uc...@google.com>
ag...@google.com <ag...@google.com> #2
This looks like a regression from AGP 3.4 to AGP 3.5. Ian, can you have a first look?
ze...@google.com <ze...@google.com> #3
Thank you very much for the reproduction project! It does indeed reproduce the issue locally. The issue appears to be the compiler failing to rewrite the invocation to a public static interface method to target the companion class created while desugaring interface methods. I'll follow up in this issue thread once more information is available and a fix is found.
ze...@google.com <ze...@google.com> #4
Reassigning to Ivan as this is looking like a build issue and I'm not sure if the project configuration needs changing or there is an error in the build system.
Running:
./gradlew :quickstartKotlin:assembleDebug --info
yields output with:
<snip>/.gradle/caches/transforms-2/files-2.1/a4e476e9d975337caa4d7a965148dce1/video-android-4.2.0/jars/classes.jar: D8: Type `org.webrtc.EglBase` was not found, it is required for default or static interface methods desugaring of `void com.twilio.video.EglBaseProvider.<init>()`
More info:
The application has a dependency on com.twilio:video-android:4.2.0 and it appears to include a copy of webrtc somehow. Found it locally in .gradle/caches/transforms-2/files-2.1/HASH/video-android-4.2.0/jars/libs/libwebrtc.jar
The definition of type com.twilio.video.EglBaseProvider in video-android-4.2.0 has an <init> with a static invoke to EglBase::create.
The interface org.webrtc.EglBase is defined in libwebrtc.jar
Outside of gradle, putting libwebrtc.jar in the program path or the classpath when compiling with D8 and a min-api to desugar default interface methods, the call to EglBase::create is correctly rewritten to EglBase$-CC::create.
Running:
./gradlew :quickstartKotlin:assembleDebug --info
yields output with:
<snip>/.gradle/caches/transforms-2/files-2.1/a4e476e9d975337caa4d7a965148dce1/video-android-4.2.0/jars/classes.jar: D8: Type `org.webrtc.EglBase` was not found, it is required for default or static interface methods desugaring of `void com.twilio.video.EglBaseProvider.<init>()`
More info:
The application has a dependency on com.twilio:video-android:4.2.0 and it appears to include a copy of webrtc somehow. Found it locally in .gradle/caches/transforms-2/files-2.1/HASH/video-android-4.2.0/jars/libs/libwebrtc.jar
The definition of type com.twilio.video.EglBaseProvider in video-android-4.2.0 has an <init> with a static invoke to EglBase::create.
The interface org.webrtc.EglBase is defined in libwebrtc.jar
Outside of gradle, putting libwebrtc.jar in the program path or the classpath when compiling with D8 and a min-api to desugar default interface methods, the call to EglBase::create is correctly rewritten to EglBase$-CC::create.
ga...@google.com <ga...@google.com> #5
As a workaround you can add "android.enableDexingArtifactTransform.desugaring=false" to gradle.properties.
In Android Gradle Plugin 3.5 we started dexing and desugaring using Gradle artifact transforms. This allows us to use Gradle caching and parallelism. The way we set up desugaring classpath is by using dependencies information from the POM file. In this case, "video-android-4.2.0" packages libwebrtc.jar inside the AAR and we fail to add those files to desugaring classpath. D8 is unable to resolve types and to rewrite invocation to the generated companion class.
In Android Gradle Plugin 3.5 we started dexing and desugaring using Gradle artifact transforms. This allows us to use Gradle caching and parallelism. The way we set up desugaring classpath is by using dependencies information from the POM file. In this case, "video-android-4.2.0" packages libwebrtc.jar inside the AAR and we fail to add those files to desugaring classpath. D8 is unable to resolve types and to rewrite invocation to the generated companion class.
vy...@gmail.com <vy...@gmail.com> #6
Note, I am facing the same issue in an app that uses a library, lets call it libraryB, that make use of webrtc but I don't include webrtc.jar in libraryB, as I use implementation configuration for libraryB. I then generates an AAR of it and import this AAR as a module to make use of it on final app. Therefore in app's build.gradle file I also import webrtc as implementation.
I have attached an android project so you can reproduce this case. webrtclibAAR module is an AAR file generated by running gradle assemble task on webrtclib module
I have attached an android project so you can reproduce this case. webrtclibAAR module is an AAR file generated by running gradle assemble task on webrtclib module
vy...@gmail.com <vy...@gmail.com> #7
Continuing my last comment:
Also I've noticed that uploading libraryB to a Nexus Server instead of using AAR as a module works properly
Also I've noticed that uploading libraryB to a Nexus Server instead of using AAR as a module works properly
ga...@google.com <ga...@google.com> #8
The issue is that we need AAR to have POM alongside to contain all dependency information. When just dropping an AAR to an output directory, this information is lost. However, when publishing to a Maven repo, this information exists.
Also, this is not exactly the same issue as the original reporter reported, but I hope my answer helps :)
Also, this is not exactly the same issue as the original reporter reported, but I hope my answer helps :)
al...@gmail.com <al...@gmail.com> #9
Our team found a fix for this issue. We manage the video-android dependency and had to build that AAR with the latest Gradle plugin (3.5.0). Once we did that, it resolved the crash. Thank you for looking into this problem though.
[Deleted User] <[Deleted User]> #10
Never mind, this is still an issue. We found a false positive in our testing that led us to believe building video-android with gradle plugin 3.5.0 resolved the crash. It is definitely related to storing the AAR to our artifact repository in Bintray. As a sanity check we referenced the AAR locally and it works fine.
Also, thank you for sharing the workaround above! We tested adding that line to the quickstartKotlin's gradle.properties file and it resolved the crash. We'll use this as a temporary solution in the meantime.
(Used a different email address here, sorry for the confusion)
Also, thank you for sharing the workaround above! We tested adding that line to the quickstartKotlin's gradle.properties file and it resolved the crash. We'll use this as a temporary solution in the meantime.
(Used a different email address here, sorry for the confusion)
[Deleted User] <[Deleted User]> #11
Also, are there plans to resolve dependencies that are packaged outside of what's specified in a POM file within the AAR? Or would we need to ensure that a POM file is always present defining dependencies like libwebrtc.jar? Our team would like to know so we can either prioritize this work or wait for the next release of the Gradle plugin. Thanks!
ga...@google.com <ga...@google.com> #12
We will handle jars packaged under libs directory in an AAR, so there is no need to add those in the POM file. cmw@ fixed that in 3.6 (he can add more details when it got fixed), so that should work, and there is no need to add e.g. libwebrtc.jar to the POM file.
cm...@google.com <cm...@google.com> #13
I think this is fixed in 3.6.0-alpha05 by
https://android.googlesource.com/platform/tools/base/+/f7f446e6c304b035e347eccd181e2b6ee4b16d97#
which merges all of the the libs jars from the AAR into one jar rather than exporting all of them separately, meaning that the classes in an AAR are all desugared together.
which merges all of the the libs jars from the AAR into one jar rather than exporting all of them separately, meaning that the classes in an AAR are all desugared together.
[Deleted User] <[Deleted User]> #14
Great! Thank you for the update on this.
vy...@gmail.com <vy...@gmail.com> #15
I'm afraid this is not solved yet. Before my last comment (https://issuetracker.google.com/issues/140508065#comment6 ) I've tested it on Android Studio Canary with 3.6.0-alpha10, and I took the same error.
cm...@google.com <cm...@google.com> #16
That is a subtly different issue, as you are not embedding the AAR. In general please file separate issues.
Your issue is that you've lost the dependency information by importing the aar as a subproject. I wish we didn't have a template for that as it leads to issues like this.
The way to solve your issue is to publish the AAR to e.g. a local maven repository so the dependency information is preserved and everything will work.
Your issue is that you've lost the dependency information by importing the aar as a subproject. I wish we didn't have a template for that as it leads to issues like this.
The way to solve your issue is to publish the AAR to e.g. a local maven repository so the dependency information is preserved and everything will work.
sh...@airvet.com <sh...@airvet.com> #17
Any update on this? This still isn't resolved in 3.5.1 and I'm stuck on the older version still. Several people in this thread have the same issue and are waiting for this to be resolved.
https://github.com/twilio/video-quickstart-android/issues/430
cm...@google.com <cm...@google.com> #18
See #13: This is not resolved in 3.5.1, it is resolved in 3.6.0-alpha05.
cm...@google.com <cm...@google.com> #19
We're considering a cherry-pick for this for a subsequent 3.5.x
[Deleted User] <[Deleted User]> #20
That would be very helpful! The sooner the better.
ar...@squareup.com <ar...@squareup.com> #21
We encountered the same issue when trying to add JAR file packaged with AAR as a local dependency.
Workaround "android.enableDexingArtifactTransform.desugaring=false" worked for us.
Then I tried 3.6.0-beta01 and 4.0.0-alpha01 and both versions didn't work - issue is still there.
Workaround "android.enableDexingArtifactTransform.desugaring=false" worked for us.
Then I tried 3.6.0-beta01 and 4.0.0-alpha01 and both versions didn't work - issue is still there.
ga...@google.com <ga...@google.com> #22
Re #21:
Thanks for the report. Which artifact contains the interface with a default method, and where is the class that implements it defined? If you are able to share a sample project that would be great.
Thanks for the report. Which artifact contains the interface with a default method, and where is the class that implements it defined? If you are able to share a sample project that would be great.
ar...@squareup.com <ar...@squareup.com> #23
I was able to isolate the issue and make a demo project to reproduce it. Tested on Android Studio 3.6.0-beta01 with AGP 3.6.0-beta01 - issue is still reproducible.
Steps to reproduce:
1. Download and import attached project
2. There will be two modules: app and library
app depends on 'library' and on 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
library depends on 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
3. Initial sync will fail because app depends directly on generated AAR. This file would be generated by :library:assemble task inside the /library/build/outputs/aar/
Run ./gradlew :library:assemble to assemble the 'library' module
4. After library is assembled try Gradle Sync button again. Now it should sync just fine.
5. Create an emulator that runs pre-java8 API, I was testing on Nexus 5 API 21 (required to enable desugaring)
6. Run app on the emulator. Upon launch app will crash.
7. In app/build.gradle comment out this:
implementation(name: 'library-debug', ext: 'aar')
And uncomment this line:
implementation project(":library")
8. Try running app again. With this module dependency app will run fine and activity will be displayed.
9. Revert step #7 to make dependency to be 'aar' again
10. In gradle.properties uncomment following line
android.enableDexingArtifactTransform.desugaring=false
11. Try running app. With this workaround app will run fine.
Explanation of the bug cause:
- Lifecycler-common-java8 contains an interface DefaultLifecycleObserver with default implementation on 6 methods
- 'library' has a class 'MyCustomObserver : DefaultLifecycleObserver' which overrides only 2 methods from DefaultLifecycleObserver
- 'app' instantiates 'MyCustomObserver' in its Application onCreate() and attempts to call method on it which is NOT overridden in 'MyCustomObserver'
Checking the bytecode for the case when AAR is used I found that 'MyCustomObserver' would only have two methods in it.
In the bytecode for the module dependency (steps #7-8) 'MyCustomObserver' has 6 methods, where 4 of those are synthetic and pointing to static methods generated by D8 in the 'DefaultLifecycleObserver$-CC' class
To sum things up, it looks like D8 cannot figure out where to get 'DefaultLifecycleObserver' while processing 'MyCustomObserver' - because AAR doesn't have any dependencies - and therefore it doesn't generate any synthetic methods for it.
Steps to reproduce:
1. Download and import attached project
2. There will be two modules: app and library
app depends on 'library' and on 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
library depends on 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
3. Initial sync will fail because app depends directly on generated AAR. This file would be generated by :library:assemble task inside the /library/build/outputs/aar/
Run ./gradlew :library:assemble to assemble the 'library' module
4. After library is assembled try Gradle Sync button again. Now it should sync just fine.
5. Create an emulator that runs pre-java8 API, I was testing on Nexus 5 API 21 (required to enable desugaring)
6. Run app on the emulator. Upon launch app will crash.
7. In app/build.gradle comment out this:
implementation(name: 'library-debug', ext: 'aar')
And uncomment this line:
implementation project(":library")
8. Try running app again. With this module dependency app will run fine and activity will be displayed.
9. Revert step #7 to make dependency to be 'aar' again
10. In gradle.properties uncomment following line
android.enableDexingArtifactTransform.desugaring=false
11. Try running app. With this workaround app will run fine.
Explanation of the bug cause:
- Lifecycler-common-java8 contains an interface DefaultLifecycleObserver with default implementation on 6 methods
- 'library' has a class 'MyCustomObserver : DefaultLifecycleObserver' which overrides only 2 methods from DefaultLifecycleObserver
- 'app' instantiates 'MyCustomObserver' in its Application onCreate() and attempts to call method on it which is NOT overridden in 'MyCustomObserver'
Checking the bytecode for the case when AAR is used I found that 'MyCustomObserver' would only have two methods in it.
In the bytecode for the module dependency (steps #7-8) 'MyCustomObserver' has 6 methods, where 4 of those are synthetic and pointing to static methods generated by D8 in the 'DefaultLifecycleObserver$-CC' class
To sum things up, it looks like D8 cannot figure out where to get 'DefaultLifecycleObserver' while processing 'MyCustomObserver' - because AAR doesn't have any dependencies - and therefore it doesn't generate any synthetic methods for it.
cm...@google.com <cm...@google.com> #24
You've just described the issue in #16, not the original issue: if the AAR doens't come from a problject or a repository with dependency information it cannot be desugared correctly.
The supported way to do this is to distribute the AAR in a repository for your consumers. Alternatively avoid using java8 in libraries that you know will be shipped this way.
Ivan, do you think it's worth having a separate code path for file based AARs, like we do for jars to cover this case?
The supported way to do this is to distribute the AAR in a repository for your consumers. Alternatively avoid using java8 in libraries that you know will be shipped this way.
Ivan, do you think it's worth having a separate code path for file based AARs, like we do for jars to cover this case?
cm...@google.com <cm...@google.com> #25
(Assign back to me for the original issue)
ga...@google.com <ga...@google.com> #26
Chris, let's keep this bug focused on jars packaged inside AARs? I've filed https://issuetracker.google.com/143744598 to discuss use case from #23.
cm...@google.com <cm...@google.com> #27
We're missing an additional change to fix the named issue - specifically
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/dependency/DexingTransform.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/dependency/DexingTransform.kt
@@ -198,7 +198,7 @@ data class DexingArtifactConfiguration(
parameters.libConfiguration.set(libConfiguration)
}
}
- spec.from.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.PROCESSED_JAR.type)
+ spec.from.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.CLASSES.type)
if (needsShrinkDesugarLibrary) {
spec.to.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.DEX_AND_KEEP_RULES.type)
fixes the issue as that means the new artifact transform is used.
I'll make the change.
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/dependency/DexingTransform.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/dependency/DexingTransform.kt
@@ -198,7 +198,7 @@ data class DexingArtifactConfiguration(
parameters.libConfiguration.set(libConfiguration)
}
}
- spec.from.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.PROCESSED_JAR.type)
+ spec.from.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.CLASSES.type)
if (needsShrinkDesugarLibrary) {
spec.to.attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.DEX_AND_KEEP_RULES.type)
fixes the issue as that means the new artifact transform is used.
I'll make the change.
cm...@google.com <cm...@google.com>
cm...@google.com <cm...@google.com> #28
This should be fixed in AGP 3.6.0-beta05
sa...@gmail.com <sa...@gmail.com> #30
I still can reproduce issue that I believe related to this bug
Environment
- android studio 3.6.3
- android gradle plugin 3.6.3
- android webrtc 1.0.26885 (also tried 1.0.30039)
- compileSdkVersion 29, targetSdkVersion 29, minSdkVersion 21
Issue
Try to initiate audio voip calls, which fails because library "libjingle_peerconnection_so.so" (webrtc dependency) fails to create correct SDP (session description protocol) with supported media types.
Workarounds
- Workaround 1> Change project minSdkVersion to 24, really helped and issue fixed. but of course can't consider it as real fix
- Workaround 2> Setting flag android.enableDexingArtifactTransform.desugaring to false.
Environment
- android studio 3.6.3
- android gradle plugin 3.6.3
- android webrtc 1.0.26885 (also tried 1.0.30039)
- compileSdkVersion 29, targetSdkVersion 29, minSdkVersion 21
Issue
Try to initiate audio voip calls, which fails because library "libjingle_peerconnection_so.so" (webrtc dependency) fails to create correct SDP (session description protocol) with supported media types.
Workarounds
- Workaround 1> Change project minSdkVersion to 24, really helped and issue fixed. but of course can't consider it as real fix
- Workaround 2> Setting flag android.enableDexingArtifactTransform.desugaring to false.
yo...@gmail.com <yo...@gmail.com> #31
@30 this issue was marked as fixed back in November. I suggest you file a new issue.
yo...@gmail.com <yo...@gmail.com> #32
Also, try Android Gradle plugin 4.0 and 4.1 and see if you get the same problem with those.
Description
AI-191.8026.42.35.5791312, JRE 1.8.0_202-release-1483-b49-5587405x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.14.6, screens 1920x1200, 1680x1050; Retina
AS: 3.5; Android Gradle Plugin: 3.5.0; Gradle: 5.4.1; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: 3.10.2, from PATH: (not found)
IMPORTANT: Please read
STEPS TO REPRODUCE ERROR:
1) Clone the following GitHub repo:
2) Open project with Android Studio 3.5.0
3) Run the quickstartKotlin run configuration on a physical device or an emulator.
4) The app should crash immediately after launch with the following stack trace:
2019-09-04 16:30:01.881 9609-9609/com.twilio.video.quickstart.kotlin E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.twilio.video.quickstart.kotlin, PID: 9609
java.lang.NoSuchMethodError: No static method create()Lorg/webrtc/EglBase; in class Lorg/webrtc/EglBase; or its super classes (declaration of 'org.webrtc.EglBase' appears in /data/app/com.twilio.video.quickstart.kotlin-Y5okEFOXkQ17caaQQ6aoLg==/base.apk)
at com.twilio.video.EglBaseProvider.<init>(EglBaseProvider.java:93)
at com.twilio.video.EglBaseProvider.instance(EglBaseProvider.java:37)
at com.twilio.video.MediaFactory.instance(MediaFactory.java:50)
at com.twilio.video.LocalVideoTrack.create(LocalVideoTrack.java:171)
at com.twilio.video.LocalVideoTrack.create(LocalVideoTrack.java:60)
at com.twilio.video.quickstart.kotlin.VideoActivity.onResume(VideoActivity.kt:453)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
at android.app.Activity.performResume(Activity.java:7939)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
ADDITIONAL NOTES:
We found a couple workarounds to resolve the crash such as:
1) Setting the minSdk version to 21.
2) android.enableD8.desugaring=false
However, we need to support API versions 16+. This is not an issue when using older versions of the gradle plugin so it appears to be an issue with the latest Android Gradle plugin version 3.5.0.