我正在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。
我已经按照从 Eclipse 迁移更新了 SDK 并从 Eclipse 导出了项目。
现在我有了 Android Studio 所需的项目结构。它们是项目对 ABS、Google Play 服务库和 android multidex 支持库的依赖。我已将这些库添加到名为“libraries”的项目文件夹中。
项目 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 或者我缺少什么?任何帮助将不胜感激。:)