更新时间:2023-11-10 18:02:28
如果您正在使用摇篮/ Android的工作室,你可以添加到您的摇篮配置:
If you are using Gradle/Android Studio, you can add this to your gradle configuration:
android {
....
dexOptions {
preDexLibraries = false
}
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
// this is optional
// dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString()
}
}
然后你需要添加multidex支持库罐子,位于 SDK /演员/安卓/支持/ multidex /库/库
。并安装它通过从 MultiDexApplication
扩展您的应用程序,或调用 Multidex.install()
从应用程序的 attachBaseContext
方法。
Then you need to add the multidex support library jar, located in sdk/extras/android/support/multidex/library/libs
. And install it either by extending your application from MultiDexApplication
, or calling Multidex.install()
from your application's attachBaseContext
method.
有关更详细看这个博文:的 http://blog.osom.info/2014/10/multi-dex-to-rescue-from-infamous-65536.html
For more details look at this blogpost: http://blog.osom.info/2014/10/multi-dex-to-rescue-from-infamous-65536.html
更新:
下面 https://developer.android.com/tools/building/multidex.html 你可以找到使用multidex有摇篮的正式方法。
Here https://developer.android.com/tools/building/multidex.html you can find the official way to use multidex with Gradle.
基本上你需要改变你的摇篮文件是这样的:
Basically you need to change your gradle file like this:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
和设置您的应用程序类android.support.multidex.MultiDexApplication或者如果你已经有一个应用程序类,你可以覆盖attachBaseContext()方法,并调用MultiDex.install(本),以使multidex。
And set your Application class to android.support.multidex.MultiDexApplication or if you already have an Application class you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex.