Status Update
Comments
h4...@gmail.com <h4...@gmail.com> #2
ja...@google.com <ja...@google.com> #3
h4...@gmail.com <h4...@gmail.com> #4
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.
uc...@google.com <uc...@google.com>
ja...@google.com <ja...@google.com> #5
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.
h4...@gmail.com <h4...@gmail.com> #6
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
wo...@gmail.com <wo...@gmail.com> #7
Also I've noticed that uploading libraryB to a Nexus Server instead of using AAR as a module works properly
wo...@gmail.com <wo...@gmail.com> #8
Also, this is not exactly the same issue as the original reporter reported, but I hope my answer helps :)
to...@gmail.com <to...@gmail.com> #9
a....@gmail.com <a....@gmail.com> #10
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)
ma...@marcardar.com <ma...@marcardar.com> #11
da...@google.com <da...@google.com> #12
ma...@marcardar.com <ma...@marcardar.com> #13
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.
da...@google.com <da...@google.com> #14
ma...@marcardar.com <ma...@marcardar.com> #15
ti...@gmail.com <ti...@gmail.com> #16
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.
[Deleted User] <[Deleted User]> #17
da...@google.com <da...@google.com> #18
hu...@google.com <hu...@google.com> #19
hu...@google.com <hu...@google.com> #20
hu...@google.com <hu...@google.com> #21
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.
lu...@booking.com <lu...@booking.com> #22
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.
hu...@google.com <hu...@google.com> #23
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.
lu...@booking.com <lu...@booking.com> #24
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?
yi...@googlemail.com <yi...@googlemail.com> #25
hu...@google.com <hu...@google.com> #26
yi...@googlemail.com <yi...@googlemail.com> #27
--- 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.
hu...@google.com <hu...@google.com> #28
yi...@googlemail.com <yi...@googlemail.com> #29
hu...@google.com <hu...@google.com> #30
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.
yi...@googlemail.com <yi...@googlemail.com> #31
@30 this issue was marked as fixed back in November. I suggest you file a new issue.
hu...@google.com <hu...@google.com> #32
Also, try Android Gradle plugin 4.0 and 4.1 and see if you get the same problem with those.
yi...@googlemail.com <yi...@googlemail.com> #33
Thank you for the excellent summary! It would be great to cherrypick the fix, but we >don't know which change has fixed it. Our team is cc'd on this thread, so if this >rings a bell to anyone, please chime in.
As an additional hint, the FragmentMainBinding.java file in my issue of Unresolved reference stated in app/build/generated/data_binding_base_class_source_out/debug/out/mypackage/databinding/FragmentMainBinding.java
, i assume that is why i can compile. Maybe it is a more kt editor related issue. The project code used is from
hu...@google.com <hu...@google.com> #34
Got it. By the way, if you could share a sample project with this issue, that would greatly increase our chance of debugging it.
yi...@googlemail.com <yi...@googlemail.com> #35
Sure, please find my
You will find two modules in this project, app module and final module. Both modules will compile and run in AVD. When you open the app/java/com.example.android.firebaseui_login_sample/MainFragment.kt
file you shall see the error in Editor unresolved reference: FragmentMainBinding
.
But when you open the same file in module final/java/com.example.android.firebaseui_login_sample/MainFragment.kt
the editor can indeed find the reference.
When you execute the following procedure:
- In terminal
cp -r final test
# duplicate the module - Open project
settings.gradle
and replaceinclude ':final', ':app'
withinclude ':final', ':app', ':test'
- clean project and rebuild project in Menu Build in AS 4.2 rc2
- You will see now the
final/java/com.example.android.firebaseui_login_sample/MainFragment.kt
also shows theunresolved reference
I assume, the Editor in AS 4.1 RC2 can resolve only one Databinding Reference in a multi-module project when all modules are duplicated. I might really hit a total different issue.
AS 4.2 Canary 9 resolves my issue and don't have problem with multiple modules have the same data binding references in the project. I hope this may help you track down the fix and cherry pick it back to AS 4.1 RC3.
hu...@google.com <hu...@google.com> #36
Great, I've filed
Description
e: /.../ExampleFragment.kt: (16, 35): Unresolved reference: databinding
e: /../ExampleFragment.kt: (33, 33): Unresolved reference: ExampleFragmentBinding
e: /../ExampleFragment.kt: (36, 15): Unresolved reference: ExampleFragmentBinding
Code:
L16: import example.ExampleFragmentBinding
L33: private lateinit var binding: ExampleFragmentBinding
L34:
L35: override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
L36: binding = ExampleFragmentBinding.inflate(inflater)
L37: return binding.root
L38: }
The editor is fine with ExampleFragment.kt and ExampleFragmentBinding, no errors there.
Build: AI-192.6262.58.36.5863777, 201909092340,
AI-192.6262.58.36.5863777, JRE 1.8.0_212-release-1586-b4-5784211x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.14.6, screens 1920x1080, 1680x1050; Retina
AS: 3.6 Canary 11; Kotlin plugin: 1.3.50-release-Studio3.6-1; Android Gradle Plugin: 3.6.0-alpha11; Gradle: 5.6.2; 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: (not found), from PATH: (not found)