Skip to main content

How to solve Multidexing problem in Android

            Steps to remove multidexing Problem in Android

What is multidex file and why we need for the APK file?
Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.
How to configure our application for multidex?

1. Add  dependency in your app build.gradle(Module:app) and Click on  Sync

 If your API Level is 20 or less than 20 you need  to add support library

    dependencies {
        compile 'com.android.support:multidex:1.0.1'       
 }

  But If your API Level is 21 or more than 21 you do not need  to add support library

2. Insert this line of code in your  build.gradle(Module level) file 

       android {
        defaultConfig {
        minSdkVersion 21      
        targetSdkVersion 26       
        multiDexEnabled true        
               }
           }
3.Then you add this line in  Manifest file
    android:name="android.support.multidex.MultiDexApplication"
 Example:
  <application
    android:allowBackup="true"  
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name"  
    android:supportsRtl="true"  
    android:theme="@style/AppTheme"  
    android:name="android.support.multidex.MultiDexApplication">
4. Create a java file and extends MultiDexApplication in it and install mutidex in it
Example:
public class Myapplication extends MultiDexApplication {
    @Override    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
5.  Click on Sync project

Comments

Popular posts from this blog

How to align Title at center of ActionBar in Android

How to Align Title At Center of Action Bar in Android                                                                                                                                                @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("DashBoard"); }   Activity  public void setTitle ( String title ){ getSupportActionBar (). setHomeButtonEnabled ( true ); getSupportActionBar (). setDisplayHomeAsUpEnabled ( true ); TextView textView = new TextView ( this ); textView . set...

Expected a key while parsing a block mapping (Flutter)

Flutter makes use of the Dart packaging system, pub. Via your applications  pubspec.yam l file (or simple pubspec), you can pull down packages from the flutter ecosystem, or the broader dart community. Anyway, i need to add some images to my flutter application, and so had to add an assets section to the pubspec .the default Android Studio generated apps pubspec has a lot of commented out code with explainations about what is going on, e.g # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware. So I uncommented these lines # assest : - - - #  -  images/a_dot_ham.jpeg with the idea from these comment.  that i would just edit it to suit my particular needs. Once you have edited your  pubspec, you need to click on the "Get dependenc...

Difference Between Pending Intent And Intent in Android

                       Normal Intent       Normal Intent will die as soon as the app being killed.    An Android Intent is an object carrying an intent, i.e a message from one Component to another     Component either inside or outside of the application.Intent can communicate message among     any of the three core Components of an application -- Activities, Services,and BroadcastReceivers.     Two types of Intent in Android   1. Explicit Intent.   2.Implicit Intent  Explicit Intent is an Intent which is used to Call the another component Explicitly in your application  Like :We are calling  Next activity on button click of First activity using Intent Example  // Explicit Intent by specifying its class name Intent i = new Intent ( this , TargetActivity . class ); i . putExtra ( "Key1" , "ABC" ); ...