Android - App crashes on Pre-Lollipop devices

蹲街弑〆低调 提交于 2019-12-03 03:32:35
Nirmal

After expanding more than a hour on problem, I found that I have to do some modification in MyApplication Class like this:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // register with Active Android
        ActiveAndroid.initialize(this);
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

I have overriden the attachbaseContext method and all works fine now.

anand krish

+) Building Apps with Over 65K Method will cause this Error.

+) When your application and the libraries it references reach a certain size ( DEX file of your application can have total number of methods upto 65,536 including Android framework methods, library methods, and methods in your own code), you encounter build errors that indicate your app has reached a limit of the Android app build architecture.

+) To resolve it, include Multidex Configuration in your build.gradle like the highlighted one in picture, along with this override the attachBaseContext(Context base) method in your Application class with the below content.

public class YourParentApplication extends Application {

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
 }
}

Add this in you Androidmanifest.xml:

<application
    android:name=".YourParentApplication"
    android:allowBackup="true"
    android:icon="@drawable/radiius_logo"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/MyMaterialTheme">

For more information about Multidex refer these site: http://developer.android.com/tools/building/multidex.html

How to enable multidexing with the new Android Multidex support library

reduce your minSdkversion to that version you want to give support

in gradle file of your project

As below

minSdkVersion 10

You should lower the API in your AndroidManifest.xml Lollipop is API 21.

Check this out: API Levels Example:

   defaultConfig {
        applicationId "com.package.name"
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!