Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapsforge 0.9.0: Android dex error (mapsforge-map-android-extras) #1020

Closed
dominicschaff opened this issue Dec 8, 2017 · 13 comments
Closed
Labels

Comments

@dominicschaff
Copy link

dominicschaff commented Dec 8, 2017

I have been using maps forge 0.8.0 with great success but when updating to 0.9.0 I am unable to compile the project anymore. I am unsure what I have done wrong.

I am compiling for SDK 26 with build tools 26.0.2, using Android Studio 3
My minimum SDK is version 16 and target is 25

The dependancies I have for the maps are:

dependencies {
    compile 'org.mapsforge:mapsforge-map-android:0.8.0'
    compile 'com.caverock:androidsvg:1.2.2-beta-1'
    compile 'org.mapsforge:mapsforge-themes:0.8.0'
    compile('org.mapsforge:mapsforge-map-android-extras:0.8.0') {
        transitive = false
    }
}

Other dependancies are:

dependencies {
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.amazonaws:aws-android-sdk-core:2.6.9'
    compile 'com.amazonaws:aws-android-sdk-cognito:2.6.9'
    compile 'com.amazonaws:aws-android-sdk-sqs:2.6.9'
    compile 'com.amazonaws:aws-android-sdk-s3:2.6.9'
    compile 'com.joshdholtz.sentry:sentry-android:1.6.2'
    compile 'com.koushikdutta.ion:ion:2.2.1'
    compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
    compile 'com.journeyapps:zxing-android-embedded:3.5.0'
}

But as soon as I update to 0.9.0 (and try run on a device) I get a compile error:

Error:

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDevelopmentDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
@ludwigb
Copy link
Collaborator

ludwigb commented Dec 8, 2017 via email

@dominicschaff
Copy link
Author

I have noticed that even if I use less of the maps dependancies and only use the themes and android-extras I still get the same error (and the transitive bit doesn't seem to make much difference).

@hgoebl
Copy link

hgoebl commented Dec 8, 2017

Try to update the build-tools. I had a similar problem with another library. Just a try …

@devemux86
Copy link
Collaborator

Has been noted that new Android Studio 3 / Gradle 4 / Android plugin 3 behave a bit strange in dependencies, regarding run configurations.

Please use the latest Android build tools like officially recommended and avoid deprecated calls, e.g. compile -> implementation.

For example in apps with many dependencies, like the GraphHopper Android sample which I maintain and uses also Mapsforge/VTM libraries.
We enabled the minifyEnabled in its build type (see here) with generic proguard rules to compile and run fine.

@dominicschaff
Copy link
Author

I will try the recommendations and comment here what the result is

@dominicschaff
Copy link
Author

I updated the build tools version to 27.0.2 (which is the latest according to the SDK tools)
And updated the dependancies to:

dependencies {
    implementation 'org.mapsforge:mapsforge-map-android:0.9.0'
    implementation 'org.mapsforge:mapsforge-themes:0.9.0'
    implementation('org.mapsforge:mapsforge-map-android-extras:0.9.0')
}

I then cleaned my build, but I am getting the same issue. And as soon as I change back to 0.8.0 issue goes away.

So I have managed to get the issue down to just maps forge libraries.

Also I cannot enable the minify, as soon as I do that the app does not compile, but that is related to some other libraries I am using.

@devemux86
Copy link
Collaborator

Can you try with all Mapsforge required dependencies, as mentioned in integration guide?

BTW internet and Stack Overflow are full of questions for latest Android Studio and "Unable to merge dex" issues. Some recommend multiDexEnabled, other minifyEnabled and other to check for duplicated dependencies (via transitive).

@dominicschaff
Copy link
Author

I now have it working again. Thanks @devemux86

I added all the dependancies from "Core" and "Android"

Now it is working again.

@dominicschaff
Copy link
Author

So I am assuming one of the dependancies may have moved or something. But it is working so I am happy. Thanks for the quick responses

@devemux86
Copy link
Collaborator

  • I created a new simple project with the Getting started guide and all latest Android tools.
  • It compiles / runs fine using the Mapsforge core + Android libs as mentioned in integration guide.
  • If add also the mapsforge-map-android-extras then the troubles start.

That module doesn't even belong in Mapsforge, since handling permissions is clearly app's (not library's) responsibility and can be done with too many more intuitive ways.

@devemux86 devemux86 changed the title Android Compile Error Mapsforge 0.9.0: Android dex error (mapsforge-map-android-extras) Dec 8, 2017
@dominicschaff
Copy link
Author

I removed the extras package, as it seems I had stopped using it at some point. Also I am not sure what I was using it for either.

@devemux86
Copy link
Collaborator

I contains code for handling (some) runtime permissions, since Android 6.0 (API 23).

@dominicschaff
Copy link
Author

I handle the permissions elsewhere, as I use them in the app. Which is probably why I stopped using them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants