Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Fix proguard enabled build (Android ) #2130

Closed

Description

@mb12

Proguard enabled build fails with tons of warnings like the following.

Warning: org.apache.commons.beanutils.BeanMap$3: can't find referenced class org.apache.commons.collections.Transformer
Warning: org.apache.commons.beanutils.BeanMap$4: can't find referenced class org.apache.commons.collections.Transformer
Warning: org.apache.commons.beanutils.BeanMap$5: can't find referenced class org.apache.commons.collections.Transformer
Warning: org.apache.commons.beanutils.BeanMap$6: can't find referenced class org.apache.commons.collections.Transformer
Warning: org.apache.commons.beanutils.BeanMap$7: can't find referenced class org.apache.commons.collections.Transformer

Activity

  1. added
    Android
    on Aug 19, 2015
  2. added this to the milestone on Aug 19, 2015
  3. tobrun commented on Aug 21, 2015

    @tobrun
    Member

    To support proguard in an AAR project, following should be added to the build.gradle

    release {
        consumerProguardFiles 'proguard-android.txt'
    }
    

    This file will be packaged in the AAR and will be automatically applied in the main application project.

  4. ljbade commented on Aug 25, 2015

    @ljbade
    Contributor

    @mb12 Does @tobrunvannuland suggestion fix the problem?

  5. mb12 commented on Aug 25, 2015

    @mb12
    Author

    @ljbade No, it doesn't fix the problem. Proguard is already setup in the sample test app. Its just disabled. Changing minifyEnabled from false to true in build.gradle makes it run. However the build fails with tons of warnings. Proguard optimizes and minimizes apk size at bytecode level. So new rules would need to be added for the Mapbox SDK. It should easily knock off a couple of megs from the final apk. Once the proguard configuration file for Mapbox SDK is ready, it could be bundled into AAR project as @tobrunvannuland suggest (I haven't tried it though).

  6. tobrun commented on Aug 25, 2015

    @tobrun
    Member

    Will do some tests in next couple days, will produce some proguard configs along the way.

  7. mb12 commented on Aug 25, 2015

    @mb12
    Author

    Thanks @tobrunvannuland , it will be very useful for Android. The APK file size limit is only 50MB for Android (half that of iOS). Since we build a fat apk that contains native libs of all supported platforms, the proguard optimization to reduce apk size will be very helpful.

  8. tobrun commented on Aug 28, 2015

    @tobrun
    Member

    I have this setup working for the SNAPSHOT, while having the test app use following proguard config:

    -keep class com.mapbox.mapboxgl.annotations.* { ; }
    -keep class com.mapbox.mapboxgl.geometry.
    * { ; }
    -keep class com.mapbox.mapboxgl.http.
    * { ; }
    -keep class com.mapbox.mapboxgl.views.MapView

    -keep class com.mapbox.mapboxgl.views.NativeMapView**
    -keepclassmembers class com.mapbox.mapboxgl.views.NativeMapView** {;}
    -dontwarn okio.
    *

    Things to do:

    • Move config file to library project
    • Test release build while building from source
    • Optimise configuration further

    Current result:

    • apk size size was reduced from 13.8 MB to 13.2 MB

    Reason behind the limited result:

    • Proguard only works with java bytecode and the amount of java code is currently limited.

    FYI: I took a look at the unzipped version of the apk and I noticed following:

    • total size is 37.5 MB
    • lib folder size with native libs is 34.4 MB.

    This means that >90% of an obfuscated apk size is used up by the native libs

  9. tobrun commented on Aug 30, 2015

    @tobrun
    Member

    Implemented in PR

  10. ljbade commented on Aug 31, 2015

    @ljbade
    Contributor

    @tobrunvannuland Yeah we still working on reducing the native libs size, mostly by replace bits of dependencies with Java implementations: #2037

  11. self-assigned this
    on Aug 31, 2015
  12. bleege commented on Aug 31, 2015

    @bleege
    Contributor

    I'll look at merging #2206. Thanks @tobrunvannuland!

  13. bleege commented on Aug 31, 2015

    @bleege
    Contributor

    Tested and merged #2206. Thanks again @tobrunvannuland!

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

Metadata

Metadata

Assignees

Labels

Androidbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions