RenderTheme not found (maybe) when minifyEnabled is enable

73 views
Skip to first unread message

Paolo Dozio

unread,
Feb 12, 2019, 1:56:21 AM2/12/19
to mapsforge-dev
Hi at all,
I used the mapsforge intergration in the OSMdroid library.
Everything is fine when I use the app in debug mode.
but when I create the APK for release with "minifyEnabled true" in the build.gradle file it seems that the render theme is not found and the map is always yellow.
Maybe some code obfuscation "damage" the assets or the link to theme.

How is possible to solve this problem?
Thanks.
Paolo. 

Emux

unread,
Feb 12, 2019, 2:55:20 AM2/12/19
to mapsfo...@googlegroups.com
Have not seen such case so far using the native Mapsforge and cannot know how third-party libraries use it.

Can try some ProGuard options:

-keep class org.mapsforge.** { *; }
-dontwarn org.mapsforge.**

Or something similar or debug the apk to see what classes are actually enter in it.

--
Emux

Paolo Dozio

unread,
Feb 12, 2019, 3:05:45 AM2/12/19
to mapsforge-dev
Thanks.
I will try to do your suggestion.
I will let you know.
Thanks for your quick answer.

Paolo Dozio

unread,
Feb 12, 2019, 4:51:12 PM2/12/19
to mapsforge-dev
In order to use your library I need to add these libraries
    
   implementation 'net.sf.kxml:kxml2:2.3.0'
implementation 'com.caverock:androidsvg:1.3'
implementation 'org.osmdroid:osmdroid-mapsforge:6.0.3'

implementation 'org.mapsforge:mapsforge-core:0.10.0'
implementation 'org.mapsforge:mapsforge-map:0.10.0'
implementation 'org.mapsforge:mapsforge-map-reader:0.10.0'
implementation 'org.mapsforge:mapsforge-themes:0.10.0'
implementation 'org.mapsforge:mapsforge-map-android:0.10.0'

When I execute the proguard in order to generate the APK release I have this error

Reading library jar [/Users/paolodozio/Library/Android/sdk/platforms/android-26/android.jar]
Note: duplicate definition of library class [org.xmlpull.v1.XmlSerializer]
Note: duplicate definition of library class [org.xmlpull.v1.XmlPullParserException]
Note: duplicate definition of library class [org.xmlpull.v1.XmlPullParserFactory]
Note: duplicate definition of library class [org.xmlpull.v1.XmlPullParser]
Reading library jar [/Users/paolodozio/Library/Android/sdk/build-tools/28.0.3/core-lambda-stubs.jar]
Reading library jar [/Users/paolodozio/Library/Android/sdk/platforms/android-26/optional/org.apache.http.legacy.jar]
Note: there were 4 duplicate class definitions.


it says
 You should also not add libraries to your application that are already part of the Android runtime (notably org.w3c.domorg.xml.saxorg.xmlpull.v1org.apache.commons.logging.Logorg.apache.http, and org.json).

So I think there is a double inclusion of the Android libraries.

I tried to add one implementation at time
with this
implementation 'org.mapsforge:mapsforge-core:0.10.0'
the proguard terminate correctly

If I add also the map library 
implementation 'org.mapsforge:mapsforge-core:0.10.0'
implementation 'org.mapsforge:mapsforge-map:0.10.0'
I got the above error

I already tried to use
-dontnote org.xmlpull.v1.**
but the error is the same.

Do you have any suggestions?

Thanks.
Paolo.

Paolo Dozio

unread,
Feb 13, 2019, 12:48:04 AM2/13/19
to mapsforge-dev
I understood what was..
The rule

-dontnote org.xmlpull.v1.**

was in the correct file, but not in the correct folder.
Now it works.
Sorry for this.
Reply all
Reply to author
Forward
0 new messages