Skip to content

Building Android package via maven fails #1144

Closed

Description

@karussell

It seems that since the update to mapsforge/vtm 0.8.0 we can no longer build the Android demo (at least via maven). The problem is the class clash of two different jts jars: one older 1.13 (from gh-core) and the 1.14 jts-core from mapsforge vtm-jts - see this change.

The cleanest way would be to upgrade to 1.14 for gh-core. @michaz what blocking issues are there to do so? I remember it was GeoJSON related but as mapsforge does also related stuff - maybe @devemux86 can help?

  • fix dep problem or workaround the issue for now via some dep exclusion
  • the NetBeans graph dependency viewer shows a clash for slf4j-api: 1.7.12 vs. 1.7.21 ... In GH we usually use 1.7.25 and now there is also a more recent slf4j-android so we should be able to update this.

BTW: The error message when executing mvn -P include-android -DskipTests=true clean install was a bit cryptic:

[ERROR] Failed to execute goal com.simpligility.maven.plugins:android-maven-plugin:4.4.3:dex (default-dex) on project graphhopper-android: : MojoExecutionException: ANDROID-040-001: Could not execute: Command = ...

Executing the listed command showed me the problem:

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/vividsolutions/jts/JTSVersion;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/vividsolutions/jts/algorithm/Angle;
...

Excluding one or the other jts library does not fix the problem or causes others.

Activity

  1. added this to the 0.10 milestone on Aug 23, 2017
  2. karussell commented on Aug 23, 2017

    @karussell
    MemberAuthor

    Switching to vtm 0.7.0 did not fix the error. Switching to 0.6.0 causes some other cryptic error
    message: Uncaught translation error: com.android.dx.cf.code.SimException: signature-polymorphic method called without --min-sdk-version >= 26

    Still failing after setting platform to 26 and updating the maven android plugin to 4.5.0. Now I'm confused. Do I really have to setup the Android SDK from scratch everytime there is a problem :( ?

  3. karussell commented on Aug 23, 2017

    @karussell
    MemberAuthor

    Reinstalling the android-sdk didn't help.

  4. karussell commented on Aug 23, 2017

    @karussell
    MemberAuthor

    When executing ./gradlew build I get the same error about the SimException and min sdk version.

  5. devemux86 commented on Aug 23, 2017

    @devemux86
    Contributor

    Hmm indeed the build command fails, though the Sample work fine and can run!

    FYI
    My use on Gradle is to always disable transitive dependencies, wanting to have complete control of what gets in the apps (Android or Desktop).
    Doing so with VTM + GraphHopper libs, I have to explicitly declare JTS dependency and works with both 1.13 and 1.14.

    So I suppose here Maven still manages somehow to get JTS from some library?

    BTW how do you build Android apps with Maven, with maven-android-sdk-deployer?

  6. karussell commented on Aug 23, 2017

    @karussell
    MemberAuthor

    Hmm indeed the build command fails, though the Sample work fine and can run!

    How do you normally produce an apk with gradle? Or do you mean that just the sample started via gradle or IntelliJ works fine?

    So I suppose here Maven still manages somehow to get JTS from some library?

    I think the clash comes from the different versions of graphhopper-core vs. vtm-jts. There is no other jts involved. But even if I exclude one or the other it does not work.

    BTW how do you build Android apps with Maven, with maven-android-sdk-deployer?

    Normally, yes. But I'm open to switch to gradle for the Android demo.

  7. devemux86 commented on Aug 23, 2017

    @devemux86
    Contributor

    I meant that the Sample "runs" via Android Studio in the emulator or in the device.
    When perform a Gradle build, then we see the issue.

    So I tested all ways and run + build can work with everyone:

    1. Exclude JTS from VTM and remove its explicit declaration, let it come from GraphHopper:
        compile('org.mapsforge:vtm-jts:0.8.0') {
            exclude group: 'com.vividsolutions', module: 'jts-core'
        }
    //    compile 'com.vividsolutions:jts-core:1.14.0'
    1. Exclude JTS from GraphHopper and remove its explicit declaration, let it come from VTM:
        compile(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.10-SNAPSHOT') {
            ...
            exclude group: 'com.vividsolutions', module: 'jts'
        }
    //    compile 'com.vividsolutions:jts-core:1.14.0'
    1. Exclude JTS from both VTM + GraphHopper and declare one of its versions explicitly:
        compile(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.10-SNAPSHOT') {
            ...
            exclude group: 'com.vividsolutions', module: 'jts'
        }
        compile('org.mapsforge:vtm-jts:0.8.0') {
            exclude group: 'com.vividsolutions', module: 'jts-core'
        }

    and

        compile 'com.vividsolutions:jts:1.13'

    or

        compile 'com.vividsolutions:jts-core:1.14.0'
  8. devemux86 commented on Aug 23, 2017

    @devemux86
    Contributor

    I prefer the 3rd method in development, to clearly see what dependencies each lib introduces.
    But since VTM doesn't have issues with JTS 1.13, can use the 1st solution in GraphHopper sample?

  9. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    Thanks! (For the moment I would also use the 1st solution)

    And finally got it working with gradle and also maven.

    A further problem in maven (with the SimException) was due to the latest build tools!? After I did:

    sdkmanager --uninstall "build-tools;26.0.0"
    sdkmanager --uninstall "build-tools;26.0.1"

    The maven stuff worked too! And you see the same SimException problem in gradle when you edit build.gradle and set:

        compileSdkVersion 26
        buildToolsVersion "26.0.1"
    
  10. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    Found the solution via the commit after this comment groovy/groovy-android-gradle-plugin#145 (comment)

  11. devemux86 commented on Aug 24, 2017

    @devemux86
    Contributor

    Always work with latest Android tools and don't have such issues.
    e.g. my tests were with build tools 26.0.1

    But didn't send a PR since you told me to not change all the time the Sample when Android advances its versions.

  12. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    Always work with latest Android tools and don't have such issues.

    This is strange as I installed the android sdk and gradle all from scratch :(
    I'll keep the build.gradle then with the 26er version

    But didn't send a PR since you told me to not change all the time the Sample when Android advances its versions.

    No problem, will commit the necessary changes also to the pom.xml

  13. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    e.g. my tests were with build tools 26.0.1

    BTW: the issue remains if I used 26.0.0 ...

  14. 2 remaining items

  15. devemux86 commented on Aug 24, 2017

    @devemux86
    Contributor

    BTW: the issue remains if I used 26.0.0 ...

    Well I recommend to not keep Sample on old Android versions.
    The tools advance for a reason, also fixing things besides improvements, so trying to solve issues with old versions only consumes our time? 🙂

  16. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    Not sure what you mean :) ... for me it does not work for 26.0.1 and also not for 26.0.0. Only with 25.0.0 I got it build successfully.

  17. devemux86 commented on Aug 24, 2017

    @devemux86
    Contributor

    That's very strange, working with 26.0.1 from its start without issues..
    Of course with all environment aligned, Android Studio 2.3.3, Gradle 3.3, Android plugin 2.3.3, Android SDK 26 (fully updated), etc.

  18. michaz commented on Aug 24, 2017

    @michaz
    Member

    @michaz what blocking issues are there to do so?

    The issue is that two other dependencies (gtfs-lib, and, more importantly, the Jackson bindings for JTS) declare JTS 1.13, which in itself is not a problem, but they switched from one jar to several jars between them (jts -> jts-core, ... ), which means that Maven doesn't know that one supersedes the other.

    So I updated to jts-core 1.14.0 now and manually excluded the monolithic JTS from the dependencies.

    This means that only tests can prevent ClassNotFoundExceptions in case one of the dependencies tries to use something which is in jts but not in jts-core. :-}

    But should be fine.

    And graphhopper-core gets a bit smaller.

  19. karussell commented on Aug 24, 2017

    @karussell
    MemberAuthor

    Thanks!

    It looks like 1.15 is around the corner (see slide 5 here) and if that will be the case I'll ask/help those dependencies to upgrade so we reduce potential license problems when using GH in iOS or Android (due to the LGPL).

  20. devemux86 commented on Feb 15, 2018

    @devemux86
    Contributor

    VTM Travis config line is for installation of Android platform.

    GH Travis error is about (again) mixed dependencies in Android dex process. 🙁
    It was fixed at some tools version, let me check that again..

  21. devemux86 commented on Feb 15, 2018

    @devemux86
    Contributor

    My local builds work, can you try:

    implementation('org.mapsforge:vtm-jts:0.9.2') {
        exclude group: 'com.vividsolutions', module: 'jts'
    }
  22. devemux86 commented on Feb 15, 2018

    @devemux86
    Contributor

    BTW I integrated JTS (LocationTech) in VTM lately in mapsforge/vtm#484.

  23. karussell commented on Feb 15, 2018

    @karussell
    MemberAuthor

    Yes, good to know. We have a bit problems with used dependencies: #1039 (comment)

    The android build works now. Now I need to enable auto deployment...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions