问题
I read many discussions about this topic but no any an exact answer I found. One says you should use Android Studio instead of Eclipse because it supports Gradle and uses Maven building. But I develop games in Eclipse using libGDX and it supports Gradle and Maven building too. Another says you should add multidex.jar from your path SDK tools or from Gradle then enable it inside gradle then extends MultiDexApplication instead of Application then install it inside attachBaseContext method. Nice, but it doesn't work.
And how can I extend MultiDexApplication instead of AndroidApplication?.
Does libGDX has modification class on Application like AndroidApplication but in MultiDexAndroidApplication case?
Another says you shoud convert your project into Maven project or add some lines in pom.xml file to build many dex files!!.
I read more about this topic, but no any answer of their answers solve this problem (In libGDX using Eclipse case).
Any help!!
回答1:
You can set multi dex enabled in Gradle (android/build.gradle) like so:
android {
buildToolsVersion "23.0.2"
compileSdkVersion 23
defaultConfig {
multiDexEnabled = true
applicationId = package_name
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
disable 'ExportedContentProvider', 'IconColors'
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
instrumentTest.setRoot('tests')
}
}
I believe the only lines you need to add are:
defaultConfig {
multiDexEnabled = true
applicationId = <your_package_name>
}
来源:https://stackoverflow.com/questions/35011769/how-can-i-use-multidexapplication-in-libgdx-for-android