1

I have a strange error. I can create my build in debug and it runs fine. All the APIs communicate just fine. CLient requirements are that I need to provide an unsigned APK build to the client's playstore admin, but when I try to build an unsigned app I get the following error:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/codec/binary/Base64;
    at org.apache.http.impl.auth.BasicScheme.authenticate(BasicScheme.java:166)
    at org.apache.http.client.protocol.RequestAuthenticationBase.authenticate(RequestAuthenticationBase.java:120)
    at org.apache.http.client.protocol.RequestAuthenticationBase.process(RequestAuthenticationBase.java:83)
    at org.apache.http.client.protocol.RequestTargetAuthentication.process(RequestTargetAuthentication.java:82)
    at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133)
    at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:167)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:484)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at com.suddenlink.suddenlink2go.connection.UrlConnection.makeServiceCall(UrlConnection.java:300)
    at com.suddenlink.suddenlink2go.connection.UrlConnection.doInBackground(UrlConnection.java:486)
    at com.suddenlink.suddenlink2go.connection.UrlConnection.doInBackground(UrlConnection.java:71)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)

But ONLY when I create an unsigned APK. What about the build process for unsigned APKs would not get all the required classes?

I'm using AndroidStudio 3.2.1, build tools 38.0.3 and gradle-4.5

build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'


final def config = defaultConfig {
    applicationId "com.suddenlink.suddenlink2go.uat"
    minSdkVersion 14
    targetSdkVersion 28
    versionCode 20200
    versionName "2.2.0-RC"
}
config

buildTypes {
    release {

        signingConfig null
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}
useLibrary  'org.apache.http.legacy'
}

dependencies {
implementation(project(':androidpdfview')) {
    exclude group: 'com.android.support', module: 'support-v4'
}
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':anvatoandroidsdkcore')
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation 'com.google.android.gms:play-services:6.5.87'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation files('libs/commons-logging-1.1.2.jar')
}
Martin
  • 4,711
  • 4
  • 29
  • 37
  • Did you try clean and rebuild? – Mohammed Junaid Oct 23 '18 at 20:22
  • Does your unsigned APK use a different build flavor, and is the Apache library included in that flavor's dependencies? – TheWanderer Oct 23 '18 at 20:31
  • clean/rebuild did not help. No flavors at all – Martin Oct 23 '18 at 20:32
  • Possible duplicate of [java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64](https://stackoverflow.com/questions/6342163/java-lang-classnotfoundexception-org-apache-commons-codec-binary-base64) - see https://commons.apache.org/proper/commons-codec/download_codec.cgi – Martin Zeitler Oct 24 '18 at 02:39
  • `signingConfig null` also looks strange. possibly jars are included twice. you could use `implementation "commons-logging:commons-logging:1.1.2"` instead. – Martin Zeitler Oct 24 '18 at 02:43

0 Answers0