我的应用程序超过64k方法所以我应该实现Multidex, 最初我有问题因为"本地路径不存在"我修复了这个问题,现在gradle生成了classes1.dex和classes2.dex, 但是没有低于棒棒糖的工作..它在棒棒糖中工作正常,因为它有本机支持.error说"< 1st activity>在dex路径中不存在"
看到一些教程后,他们说必须在1.gradle 2.application class 3.manifest 中进行更改。我对申请课没有太多了解..请引导我,谢谢
注意:这是eclipse的导入项目。
请检查build.gradle文件
apply plugin: 'com.android.application'
android {
defaultConfig {
compileSdkVersion 23
buildToolsVersion '23.0.1'
minSdkVersion 15 //lower than 14 doesn't support multidex
targetSdkVersion 23
}
dexOptions {
jumboMode = true
preDexLibraries = false
javaMaxHeapSize "2048M"
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
productFlavors {
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:multidex:1.0.1'
}
答案 0 :(得分:1)
您遵循了一个教程,该教程展示了如何在 Android gradle插件支持之前手动添加多语言支持。从v0.14.0开始,您需要做的就是添加:
android {
defaultConfig {
...
multiDexEnabled true
}
您可以选择三个选项之一来调用MultiDex代码。来自MultiDexApplication documentation:
支持MinDex的最小应用程序。 要使用传统的multidex库,有3种可能性:
开始的attachBaseContext
- 将此类声明为AndroidManifest.xml中的应用程序 - 您的申请是否延伸到此课程 - 让您的应用程序覆盖从protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
不要忘记从构建脚本中删除afterEvaluate
块。
确保您已阅读official documentation。