Android obfuscate app using proguard keeps obfuscating library jars - or is it?

后端 未结 2 868
深忆病人
深忆病人 2020-12-08 03:03

I\'m new to using Proguard so I\'m probably making a newbie mistake. I\'ve got an app that after I run the release build (which uses Proguard to obfuscate) it crashes prett

相关标签:
2条回答
  • 2020-12-08 03:37

    I had a similar problem when proGuard encrypted the jsoup lib. I fixed it by adding the following to my proguard-rules.txt:

    -keep class org.jsoup** {
        *;
    }
    

    So the build.gradle will end up with the following section:

    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    
    0 讨论(0)
  • 2020-12-08 03:45

    You have commented your library jar directives in the Proguard config.
    Change:

    # -libraryjars /libs/protobuf-2.3.0.jar
    # -libraryjars /libs/libmessaging.jar
    

    to:

    -libraryjars /libs/protobuf-2.3.0.jar
    -libraryjars /libs/libmessaging.jar
    

    (and then don't bother defining your library jars in your build.xml)

    EDIT:
    I found another way to make Proguard leave library jars alone was to ask it to preserve their package names, eg:

    -keep class javax.** { *; }
    -keep class org.** { *; }
    -keep class twitter4j.** { *; }
    
    0 讨论(0)
提交回复
热议问题