I am building a small Android app with Kotlin and Android Studio. Everything worked fine, but out of the blue (at least what seems to me), I am stuck with
Error:Execution failed for task :bahndb:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest'.
> com.android.builder.dexing.DexArchiveMergerException:
Error while merging dex archives:
C:\Users\Dieter\AndroidStudioProjects\zuegliwidget\bahndb\build\intermediates\transforms\dexBuilder\androidTest\debug\13.jar,
and so on until 47.jar when I try to run an Instrumented Test. Local tests all work ok. It is strange that even earlier checkout that had worked before show this behaviour (some update? I have reinstalled Android Studio twice)
I have read all message on the subject here, none helped:
Use clean build (I do every time)
Invalidate cache (over and over)
added multiDex
Tried different Kotlin plugins
Uninstalled 3.1 Canary 5, installed stable, reinstalled canary 5
Un/commented dependencies one after the other (this had worked earlier)
Running Lint, but failed with error
App has 2 submodules, bahndb and http. Here are the gradle files, if it matters
https://github.com/dmenne/zuegliwidget/blob/master/build.gradle
https://github.com/dmenne/zuegliwidget/blob/master/app/build.gradle
https://github.com/dmenne/zuegliwidget/blob/master/bahndb/build.gradle << Most likely guilty
https://github.com/dmenne/zuegliwidget/blob/master/http/build.gradle
Is there a systematic approach to locate the source of the problem
Thanks to #CommonsWare's comments, I found that I had
implementation ('com.squareup.retrofit2:converter-simplexml:2.3.0'){
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}
in one submodule, but had forgotten the exclude-part in the other.
Related
I recently added implementation 'com.google.android.play:core:1.6.4' as a dependency in my android project and now Intellij is complaining that Program type already present: androidx.exifinterface.R. What does this mean and how do I fix this?
Note: this is meant to be a Q&A question. I've already found a solution and I want to share with others.
I recently ran into an issue where android studio would complain that Program type already present: androidx.exifinterface.R. This happened after adding the implementation 'com.google.android.play:core:1.6.4' dependency. I had stumbled on this before with androidx.asynclayoutinflater.R. I've found the that adding something like the following to your module level gradle file will fix it:
configurations.all {
// This is from a previous, similar issue
exclude group: "androidx.asynclayoutinflater", module: "asynclayoutinflater"
// This is the LOC that fixed the issue in this post
exclude group: "androidx.exifinterface", module: "exifinterface"
}
The pattern seems to be:
if there's a complaint about androidx.MODULE_X.R already being present
then add
exclude group: "androidx.MODULE_X", module: "MODULE_X"
to configurations.all in module level gradle file
This worked for both asynclayoutinflater and now exifinterface. I don't know if the pattern scales but so far it has worked. My understanding of the underlying issue is that two dependencies in the module dependency graph (eg com.google.android.play:core) explicitly include the problematic module (eg exifinterface) and so we need to exlude one of those explicit dependencies. My understanding might be wrong.
I’m working on an android application, which have to use gRPC and Firestore. However, when I added both one of module from ‘io.grpc’ group dependency (e.g. io.grpc:grpc-okhttp:1.7.0) and firestore dependency (com.google.firebase:firebase-firestore:11.4.2) in the build gradle config, I got a build error “Unable to merge dex”. After with ‘stacktrace’ build option, I saw that the problem is
Multiple dex files define Lio/grpc/internal/OobChannel$5;
It could happen if firestore uses grpc-core module, but there is no one similar in tree dependencies, which I got using [androidDependencies] gradle task. I tried to exclude io.grpc like this:
implementation ('com.google.firebase:firebase-firestore:11.4.2') {
exclude group: 'io.grpc'
}
but there was the same error. Then I thought what if I exclude all ‘io.grpc.’ transitive dependencies from grpc module dependencies with adding grpc-core for internal classes. In this way, I wrote ugly dependencies just for test
implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation('io.grpc:grpc-okhttp:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-protobuf-lite:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-stub:1.7.0') {
exclude group: 'io.grpc'
}
implementation 'io.grpc:grpc-core:1.7.0'
I was surprised when it successfully compiled, but after launch app, it crashed with java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev)
Caused by: java.lang.NoSuchMethodError: No static method zzcyc()Lio/grpc/ManagedChannelProvider; in class Lio/grpc/ManagedChannelProvider; or its super classes (declaration of 'io.grpc.ManagedChannelProvider' appears in /data/app/com.zipr.test-2/split_lib_dependencies_apk.apk)
I use gradle 3.0.0-rc1 with enabling multidex support. I deleted .gradle, build directories, cleaned rebuilt project, but I still have build error. What can I do to resolve this problem?
Due to a variety of factors that constrain the way we build Android SDKs at Google, Firestore proguards a copy of gRPC within itself. Unfortunately this is leaky and you're running into the fallout: the 11.4.2 Firestore SDK is incompatible with any external gRPC :-(.
This is essentially our top issue for the Firestore Android SDK and I'm sorry you've run into it.
I´m using multiple Calendar libraries for a demo aplication for android.
Including Flexible Calendar and Caldroid, both uses Infinite View Pager library, and it gives me Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' because f the duplicated class files:
java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/antonyt/infiniteviewpager/InfinitePagerAdapter;
So I enabled multidex and I was trying to exlude that library from one of those libraries but I can´t get the expected result.
I tried:
compile ('com.p_v:flexiblecalendar:1.2.1'){
exclude group: 'com.antonyt.infiniteviewpager', module: 'library'
}
and this
compile ('com.p_v:flexiblecalendar:1.2.1'){
exclude group: 'com.antonyt.infiniteviewpager'
}
and this
compile ('com.p_v:flexiblecalendar:1.2.1'){
exclude group: 'antonyt.infiniteviewpager'
}
But it doesn´t work. Im still getting the MultiDex error
Which one is the right way to acomplish this?
It can't work since these libs don't have the module com.antonyt.infiniteviewpager inside.
You can check the dependencies in the build.gradle of each library.
Also you can find the source of the InfinitePagerAdapter in each library (check link1 and link2).
Since the libraries seems to be not updated and quite easy to build you can download one of these as a local module in your project avoiding the duplicate.
i'm having the following issue on building an Android Cordova.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
The problem only happens when i use Wizcorp/Facebook with AdMob-Pro.
You need to exclude android-support-v4.jar that got included by Wizcorp Facebook plugin. Trick is simple you need to create build-extras.gradle inside platforms/android and add following:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
the solution is in this post, but doesn't work in my case.
#mladen5 solution, not mine.
I'm pretty new to the Gradle build system and Android Studio and cannot quite figure out how to resolve this issue. My build is failing with:
* What went wrong:
Execution failed for task ':cyanEngine:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: javax/annotation/ParametersAreNullableByDefault.class
If I do Ctrl + N and search for ParametersAreNullableByDefault. One reference is pointing to External Libraries | jsr305-1.3.9. The other is pointing to classes.jar under xwalk_core_library.
xwalk_core_library is referenced in my xwalk_cordova module via:
{
android{
dependencies{
compile 'org.xwalk:xwalk_core_library:11.40.277.7'
}
}
And my app's gradle dependencies has:
compile project (':xwalk_cordova')
It seems like I need to get rid of the External Library, but I'm not sure where it's coming from.
Any pointers on how to resolve this?
Update:
I figured out the external reference was coming from Guava, referenced in the application build.gradle via compile ('com.google.guava:guava:11.0.2'). Just updating to Guava version 18.0 seems to get me past this for now. Guess the newer version no longer depends on jsr.
Still, I feel like I'll run into this again. Basically, we had two 3rd party libraries depending on the same library. What's the best way to clean this up?
I noticed for robolectic, there is an exclude, I'm guessing for similiar reasons:
testCompile('org.robolectric:robolectric:3.0-rc2') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
I'm curious how this statement works and don't quite understand the Gradle docs. What is this statement saying? Where do 'group' and 'module' come from?