Create apk based on mobile device Density or layout CPU type android

Android application you can build APK for specific CPU . You just need to config your app gradle
with some properties and CPU name

you can splits function to achieve your goal . now you just put below function into your app gradle file  like below mention


splits {
  
    abi {
      
          // Enables building multiple APKs per ABI.   
           enable true       
         // By default all ABIs are included, so use reset() and include to specify that we only       
         // want APKs for x86, armeabi-v7a, and mips.
         // Resets the list of ABIs that Gradle should create APKs for to none.        reset()
         // Specifies a list of ABIs that Gradle should create APKs for.     
           include "x86", "armeabi-v7a"     
        // Specifies that we do not want to also generate a universal APK that includes all ABIs.  
           universalApk false   
   }
}


   In this code I config here 2 type CPU "x86" and "armeabi-v7a" and based on 
   this APK will be generate .  


   




Full gradle file details below 

apply plugin: 'com.android.application'
android {
    compileSdkVersion 29   
 buildToolsVersion "29.0.2"  
  defaultConfig {
        applicationId "com.ntss.test"   
     minSdkVersion 19     
   targetSdkVersion 29    
    versionCode 1   
     versionName "1.0"      
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"    }
    buildTypes {
        release {
            minifyEnabled false     
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'     
       }
    }

    splits{

        // Configures multiple APKs based on ABI.        abi {
            // Enables building multiple APKs per ABI.            enable true            // By default all ABIs are included, so use reset() and include to specify that we only            // want APKs for x86, armeabi-v7a, and mips.            // Resets the list of ABIs that Gradle should create APKs for to none.            reset()
            // Specifies a list of ABIs that Gradle should create APKs for.            include "x86", "armeabi-v7a"            // Specifies that we do not want to also generate a universal APK that includes all ABIs.            universalApk false        }
    }

}

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'androidx.appcompat:appcompat:1.0.2'  
   implementation 'com.google.android.material:material:1.0.0' 
   implementation 'androidx.constraintlayout:constraintlayout:1.1.3'   
   implementation 'androidx.navigation:navigation-fragment:2.0.0'
   implementation 'androidx.navigation:navigation-ui:2.0.0' 
   implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
   testImplementation 'junit:junit:4.12'  
   androidTestImplementation 'androidx.test.ext:junit:1.1.0'  
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}



for more details you can see this like 













No comments:

IRCTC Share Price Declines by 2% Despite 30% Jump in Q4 Net Profit; Board Announces Dividend of INR 2 per Share

Introduction: The share price of Indian Railway Catering and Tourism Corporation (IRCTC) experienced a decline of 2% in today's trading ...