Using Maps api v2 and it works perfectly with 4.4 , 5.0, 5.1, 5.1.1 , 6 but app crashes when I try 4.2.2. I\'ve been doing lots of research but nothing seems to work. Here\'
3 Simple Steps:
Step#1: Multidexing is a new feature and so requires a support library to be compatible with pre-lollipop devices. You need to add the following to your gradle file dependencies:
compile 'com.android.support:multidex:1.0.0'
Step#2: Also enable multidex output in your gradle file:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
}
Step#3: And then add the multidex support application to your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
Note: If your app already uses(extends) the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex. For more information, see the MultiDexApplication reference documentation.
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
Here are the same instructions for reference: https://developer.android.com/tools/building/multidex.html
After some research and hours of testing I finally realized that android has something called the DEX 64K Methods Limit. In simple words there's a limit you can reach when adding external libraries to your project. When you reaches that limit you might need to use multidex. Personally I decided to reduce the amount of libraries imported as some of them weren't really used or necesary. For further understanding of multidex you should read this,
http://developer.android.com/tools/building/multidex.html