Shrink Debug Multi Dex Component; Cannot Read dir/allclasses.jar

I am developing an application which enabling Multidex in order to avoid 65k limit. I want to add an external library in Jar type (i.e. iPay Jar SDK). I've Synchronized the Gradle and succeed but I failed to run the project.

The error message shown like below

Error:Execution failed for task ':app:shrinkDebugMultiDexComponents'.

java.io.IOException: Can't read [/[dir]/app/build/intermediates/multi-dex/debug/allclasses.jar] (Can't process class [com/ipay/IpayAcitivity.class] (Unknown verification type [14] in stack map frame))

This is my Gradle Code

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.2'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}

repositories {
    mavenCentral()
    mavenLocal()
}

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName '[My Package]'
    }
}

dependencies {
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"

    compile fileTree(dir: 'libs', include: ['*.jar'])
    //Libs folder contains: org.apache.http.legacy.jar
    //and ipay88_androidv7.jar

    compile 'com.loopj.android:android-async-http:1.4.5'
    compile 'com.github.rey5137:material:1.2.1'
    compile 'com.jpardogo.materialtabstrip:library:1.0.9'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'

    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "[My Application Id]"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            java.srcDirs = ['src/main/java', 'build/source/apt/debug']
            resources.srcDirs = ['src/main/res']
            res.srcDirs = ['src/main/res']
            assets.srcDirs = ['src/main/assets']
        }

        beta {
            resources.srcDirs = ['app/src/beta/res']
            res.srcDirs = ['app/src/beta/res']
        }
    }
    signingConfigs {
        release {
            ...
        }
    }
}

Before I added this type of external library (i.e. iPay Jar SDK), the application was running successfully. But the problem arised after I had added iPay Jar SDK (second Jar Library).

For further information, I had already followed this guide on https://developer.android.com/tools/building/multidex.html But it didn't work my project.

What's your suggestion to fix this error ?

Answers


Try this:

public class MyApplication extends MultiDexApplication
{
    @Override
    protected void attachBaseContext(Context base)
    {
        super.attachBaseContext( base );
    }

    @Override
    public void onCreate()
    {
        MultiDex.install(getTargetContext());
        super.onCreate();
    }

}

It seems your library is not compatible with Multidex. So you better update the library to the latest version(if an update is available). Or use only the required Google Play services API in your application and get rid off Multidex. Replace

  compile 'com.google.android.gms:play-services:8.1.0'  (the whole library)

this with something you use in your app like this

 compile 'com.google.android.gms:play-services-ads:8.1.0'  (library only for ads)

and remove this compile 'com.android.support:multidex:1.0.1'

You can find all the Google Play services API here https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project


Need Your Help

Why am I losing my characters from my html string when trying to add html dynamically using javascript

javascript jquery

I have a page that I am trying to dynamically add some links to. The links are getting added to the page fine, but the '[' and ']' at either end of the line are getting dropped. The code from my .j...

Laravel : How to get the first record of each collections in a 'with' function query

sql laravel eloquent

I want to get a collection of all artists with their latest image only.