Before, my program run well. But When I just updated my Android studio to the latest version (2.2 built on 15-sept-16), I am having the following error. When I built it, it says
In app module build.gradle
android {
...
defaultConfig {
multiDexEnabled true
...
}
}
dependencies {
// add dependency
compile 'com.android.support:multidex:1.0.1'
}
Change name in AndroidManifest.xml
<application
....
android:name=".MyApplication">
// ...
</application>
Crate a MyApplication.java file
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
For MORE details can see this link.
just remove the google play services dependencies if you are including it. I am able to fix this error everytime using this. If you are using google maps or any other specific google service then include the dependency for that particular service only. Also try to check the version of google play service dependency.
app=>build.gradle
android {
.....
defaultConfig {
......
multiDexEnabled true//add this line
}
......
dependencies{
compile 'com.android.support:multidex:1.0.1'//add this line
}
In manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
<application
....
android:name="android.support.multidex.MultiDexApplication"
...>
<activity />
...
</application>
</manifest>