Android Studio - java.lang.RuntimeException: Unable to instantiate application

1.8k Views Asked by At

I am working on a project in eclipse, but after sometime it giving me error like "Unable to execute dex: method ID not in" as single DEX file having 65k method limitations.

To overcome the issue I come into the picture of Gradle plugin v0.14.0 for Android adds support for Multi-Dex. So I moved to Android Studio.

I have updated SDK and exported project from eclipse as per Migrating from Eclipse.

Now I have project structure required in Android Studio.Their is dependency of project on ABS, Google Play Service lib and android multidex support lib. I have added these libraries to my project folder named "libraries".

Project Gradle file looks something below:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.14.1'
}
}

apply plugin: 'com.android.application'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':libraries:ABS')
compile project(':libraries:GooglePlayServiceLib')


compile (project(':libraries:android-support-multidex')) {
    exclude group: 'com.android.support', module: 'support-v4'
}


  compile "com.android.support:support-v4:21.0.0"


}


android {
compileSdkVersion 19
buildToolsVersion "20.0.0"

dexOptions {
    preDexLibraries = false


   }


sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }


    instrumentTest.setRoot('tests')


    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')

    buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }

}


}

afterEvaluate {
tasks.matching {
    it.name.startsWith('dex')
}.each { dx ->
    if (dx.additionalParameters == null) {
        dx.additionalParameters = ['--multi-dex']
    } else {
        dx.additionalParameters += '--multi-dex'
    }
}
}

When I clean and build project it builds successfully. But when I run project as android application giving me following error:

java.lang.RuntimeException: Unable to instantiate application java.lang.ClassNotFoundException: Didn't find class on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-2, /vendor/lib, /system/lib]]

I am thinking that application is not compiling AndroidManifest.xml OR I am something missing ? Any help is going to be appreciated. :)

0

There are 0 best solutions below