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...

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" ); ...

SQLite Database With Android

Android provides several ways to store user and app data. SQLite is one way of storing user data. SQLite is a very light weight database which comes with Android OS. In this tutorial I’ll be discussing how to write classes to handle all SQLite operations. SQLite is a opensource  SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relation database features. In order to access this database you don't need to establish any kind of connections for it like JDBCODBC etc. In this tutorial I am taking an example of storing user Detail in SQLite database. I am using a table called UserMaster to store user detail. This table contains three columns  id (INT) , userid (VARCHAR) , username (VARCHAR) , password (VARCHAR) , address (VARCHAR) . Database- Package The main package is android.database.sqlite that contains the classes to mange your own database. In this Class we are creat...