Trying to use MultiDexApplication in my app, but the class is not recognized when I try to extend my application activity with it.
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.1'
defaultConfig {
applicationId 'com.myapp'
minSdkVersion 10
targetSdkVersion 21
versionCode 115
versionName '4.8'
}
buildTypes {
debug {
debuggable true
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
runProguard true
zipAlign true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.1.11'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile project(':facebook')
}
You can see that I'm compiling on 21, using the latest build tools, and the latest google play services and support library.
Has anyone gotten this to work?
I have followed THIS blog post according to which MultiDexApplication should be included in r21 of support library.
My IDE had trouble resolving it also.
I made it work for now with the help of MULTIDEX github project by adding (you can see more details on the project's page):
and adding $project_dir/multidex.keep file with following contents:
The github project page mentions also some consideration for the contents of your implementation of MultiDexApplication class:
MultiDexApplication class is not part of appcompat-v7 library. It is being shipped in a separate jar (called android-support-multidex).
Find the android-support-multidex.jar under /sdk/extras/android/support/multidex/library/libs (available from revision 21 of support library) and copy it to your project's libs folder.
Update (11/5/2014):
The jar is now available in central repository:
For more info, see here.
Although this question is quite old, I got this error in a multi-module setup when trying to build the different modules together as one APK for API < 21. I already refactored to AndroidX, but the multidex docs don't mention AndroidX yet.
If you are using AndroidX, make sure to replace the old multidex dependency
with the new one
I got the solution :)
Upgrade to jdk 8 and change JDK location in Android Studio in
File > Project Structure > SDK Location
Find and change JDK location and click OK