Reputation: 15
my app exceeding 64k methods so iam supposed to implement Multidex , initially i had problem as "local path doesnt exist" i fixed that problem ,now gradle generated classes1.dex and classes2.dex , but not working in lower than lollipop..it was working fine in lollipop since it has a native support .error says that "<1st activity> is not present in dex path"
after seeing some tutorials they said that have to do a change in 1.gradle 2.application class 3.manifest
i dont have much knowledge about application class ..kindly guide me thanks
note:this is an imported project from eclipse .
kindly check build.gradle file
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'
}
Upvotes: 1
Views: 1012
Reputation: 13938
You followed a tutorial that shows how you could add multi-dex support manually before Android gradle plugin had support for it. Since v0.14.0, all you need to do is to add:
android {
defaultConfig {
...
multiDexEnabled true
}
And you can choose one of three options to call the MultiDex code. From MultiDexApplication documentation:
Minimal MultiDex capable application. To use the legacy multidex library there is 3 possibilities:
- Declare this class as the application in your AndroidManifest.xml.
- Have your Application extends this class.
- Have your Application override attachBaseContext starting withprotected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
Don't forget to remove the afterEvaluate
block from your build script.
Make sure you've read the official documentation.
Upvotes: 1