Android Studio - java.lang.RuntimeException:无法实例化应用程序

时间:2014-11-14 14:04:06

标签: android android-studio filenotfoundexception build.gradle multidex

我正在eclipse中开展一个项目,但过了一段时间它给我的错误如"Unable to execute dex: method ID not in" as single DEX file having 65k method limitations.

为了解决这个问题,我进入了Gradle plugin v0.14.0 for Android adds support for Multi-Dex.的图片所以我转移到 Android Studio。

我已根据Migrating from Eclipse.

更新了Eclipse和Eclipse中导出的项目

现在我在Android Studio中需要项目结构。他们是项目依赖于ABS,Google Play服务lib和android multidex支持lib。我已将这些库添加到名为" libraries"。

的项目文件夹中

Project Gradle文件如下所示:

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'
    }
}
}

当我清理并构建项目时,它会成功构建。但当我运行项目作为Android应用程序给我以下错误:

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]]

我在想应用程序没有编译AndroidManifest.xml或者我缺少什么? 任何帮助将不胜感激。 :)

0 个答案:

没有答案