apache commons ftp doesn't work on release build apk

110 Views Asked by At

I'm able to upload files to an FTP Server when I'm using a debug build, but it fails in the release build:

  • it fails regardless if minify is enabled or not
  • it fails even when I remove proguard settings

I am able to generate the release build apk with no errors. The upload-to-ftp feature in the app just won't work.

build.gradle

implementation 'commons-net:commons-net:3.6'

....

minifyEnabled false
shrinkResources false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable true
signingConfig signingConfigs.release

proguard-rules.pro

-keepclasseswithmembernames class * {
    native <methods>;
}
-keep class com.integratedbiometrics.** { *;}
-keep class org.libusb.** { *;}
-keep class com.futronictech.** { *;}
-keep class com.smufsbio.btsdk.** { *;}
-keep class org.apache.http.** { *; }
-keep class org.apache.commons.codec.** { *; }
-keep class org.apache.commons.logging.** { *; }
-keep class android.net.compatibility.** { *; }
-keep class android.net.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.webkit.**

What am I missing?

1

There are 1 best solutions below

0
buzzcarla On BEST ANSWER

I got it working already. I found out it was not the shrinking and obfuscating at all because setting minifyEnabled and shrinkResources to true in both release and debug build still gave me an issue with the release build while the debug build worked well.

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
    debug {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.debug
    }
}

The only difference then was the signingConfig, and when I set signingConfig signingConfigs.release in the debug build, the problem surfaced in the debug build.

Apparently, there was something wrong with the security certificate I was signing the apk with. Creating a new certificate fixed the issue for me. It's the first release so there's no issue in doing so.