My app crashes when using proguard with Hyperledger Iroha

101 views Asked by At

When i try to do minify enabled true in my build.gradle file using below code application is crashed :

Code

buildTypes {
    release {
        debuggable false
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug{
        debuggable true
        minifyEnabled true
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
  • when I did: minifyEnabled true after building release apk: app-release.apk, the app crashed.
  • when I did: minifyEnabled false after building release apk: app-release.apk, the build is okay.

enter image description here

3

There are 3 answers

0
Muhammed Yalçın Kuru On

As indicated ref resource, minifyEnabled will remove unused codes. In your situation, there might be methods which is used with JNI or else and compiler did not known it's used. Again according to ref, you can specify which files to keep from examination of built-in minify (same as proguard). The answer is here

1
Kundan Singh On

As given in the error message the classloader was not able to find the class org.apache.xerces.datatype.DatatypeFactoryImpl

Proguard is changing the class name to stop this from happening you can add

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

in your progurad-rules.pro file

1
Bhoomin Naik On

Add this to proguard

-keep public class jp.co.soramitsu.iroha.android.** {
      public protected *;
      public private *;
}