android sudio升级后报错ABIs [armeabi] are not supported for platform. Supported ABIs are [arm64-v8a, arme

Build Multiple APKs

Although you should build a single APK to support all your target devices whenever possible, that might result in a very large APK due to files needed to support multiple screen densities or Application Binary Interfaces (ABIs). One way to reduce the size of your APK is to create multiple APKs that contain files for specific screen densities or ABIs.

Gradle can create separate APKs that contain only code and resources specific to each density or ABI. This page describes how to configure your build to generate multiple APKs. If you need to create different versions of your app that are not based on screen density or ABI, you can instead use build variants.

Configure your build for multiple APKs

To configure your build for multiple APKs, add a splits block to your module-level build.gradle file. Within the splitsblock, provide a density block that specifies how Gradle should generate per-density APKs, or an abi block that specifies how Gradle should generate per-ABI APKs. You can provide both density and ABI blocks, and the build system will create a an APK for each density and ABI combination.

Note:  Generating per-language APKs is supported only for Android Instant App projects. To learn more, read Enable configuration APKs.

Configure multiple APKs for screen densities

To create separate APKs for different screen densities, add a density block inside your splits block. In your densityblock, provide a list of desired screen densities and compatible screen sizes. The list of compatible screen sizes should only be used if you need specific <compatible-screens> elements in each APK's manifest.

The following Gradle DSL options are used to configure multiple APKs for screen densities:

enable
If you set this element to  true, Gradle generates multiple APKs based on the screen densities you define. The default value is  false.
exclude
Specifies a comma-separated list of densities that Gradle should  not generate separate APKs for. Use  exclude if you want to generate APKs for most densities, but need to exclude a few densities that your app doesn't support.
reset()
Clears the default list of screen densities. Only use when combined with the  include element to specify the densities you would like to add. The following snippet sets the list of densities to just  ldpi and  xxhdpi by calling  reset() to clear the list, and then using  include.
 
   
reset ()   // Clears the default list from all densities to no densities.
include
"ldpi" , "xxhdpi" // Specifies the two densities we want to generate APKs for.
include
Specifies a comma-separated list of densities that Gradle should generate APKs for. Only use in combination with  reset() to specify an exact list of densities.
compatibleScreens
Specifies a comma-separated list of compatible screen sizes. This will inject a matching  <compatible-screens>node in the manifest for each APK. This setting provides a convenient way to manage both screen densities and screen sizes in the same  build.gradle section. However, using  <compatible-screens> can limit the types of devices your app will work with. For alternative ways to support different screen sizes, see  Support Multiple Screens.

Because each APK that's based on screen density includes a <compatible-screens> tag with specific restrictions about which screen types the APK supports, even if you publish several APKs, some new devices will not match your multiple APK filters. As such, Gradle always generates an additional universal APK that contains assets for all screen densities and does not include a <compatible-screens> tag. You should publish this universal APK along with your per-density APKs to provide a fallback for devices that do not match the APKs with a <compatible-screens> tag.

The following example generates a separate APK for each screen density listed in Range of screens supported, except ldpixxhdpi, and xxxhdpi. This is done by using exclude to remove three densities from the default list of all densities.

 
 
android {
 
...
  splits
{

   
// Configures multiple APKs based on screen density.
    density
{

     
// Configures multiple APKs based on screen density.
      enable
true

     
// Specifies a list of screen densities Gradle should not create multiple APKs for.
      exclude
"ldpi" , "xxhdpi" , "xxxhdpi"

     
// Specifies a list of compatible screen size settings for the manifest.
      compatibleScreens
'small' , 'normal' , 'large' , 'xlarge'
   
}
 
}
}

For a list of density names and screen size names, see How to Support Multiple Screens. For more details on distributing your app to specific screen types and devices, see Distributing to Specific Screens.

Configure multiple APKs for ABIs

To create separate APKs for different ABIs, add an abi block inside your splits block. In your abi block, provide a list of desired ABIs.

The following Gradle DSL options are used to configure multiple APKs per ABI:

enable
If you set this element to  true, Gradle generates multiple APKs based on the ABIs you define. The default value is  false
exclude
Specifies a comma-separated list of ABIs that Gradle should  not generate separate APKs for. Use  exclude if you want to generate APKs for most ABIs, but need to exclude a few ABIs that your app doesn't support.
reset()
Clears the default list of ABIs. Only use when combined with the  include element to specify the ABIs you would like to add. The following snippet sets the list of ABIs to just  x86 and  x86_64 by calling  reset() to clear the list, and then using  include:
 
   
reset ()   // Clears the default list from all ABIs to no ABIs.
include
"x86" , "x86_64" // Specifies the two ABIs we want to generate APKs for.
include
Specifies a comma-separated list of ABIs that Gradle should generate APKs for. Only use in combination with  reset() to specify an exact list of ABIs.
universalApk
If  true, Gradle generates a universal APK in addition to per-ABI APKs. A universal APK contains code and resources for all ABIs in a single APK. The default value is  false. Note that this option is only available in the  splits.abiblock. When building multiple APKs based on screen density, Gradle always generates a universal APK that contains code and resources for all screen densities.

The following example generates a separate APK for each ABI: x86 and x86_64. This is done by using reset() to start with an empty list of ABIs, followed by include with a list of ABIs that will each get an APK.

 
 
android {
 
...
  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 and x86_64.

     
// 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" , "x86_64"

     
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
      universalApk
false
   
}
 
}
}

For a list of supported ABIs, see Supported ABIs.

mips, mips64, and armeabi

Android Plugin for Gradle 3.1.0 and higher no longer generate APKs for the following ABIs by default: mipsmips64, and armeabi. That's because NDK r17 and higher no longer include these ABIs as supported targets.

Consider first checking the Google Play Console to verify that you have users downloading APKs of your app that target these ABIs. If not, you may want to omit them from your build. If you want to continue building APKs that target these ABIs, you must use NDK r16b or lower and specify the ABIs in your build.gradle file, as shown below:

 
 
splits { abi { include 'armeabi', 'mips', 'mips64' ... } }

Known Issue: If you are using Android Plugin for Gradle 3.0.1 or lower with NDK r17 or higher, you may get the following error:Error:ABIs [mips64, armeabi, mips] are not supported for platform. That's because older versions of the plugin still include the unsupported ABIs by default when you build per-ABI APKs. To resolve this issue, either update to the latest version of the plugin, or, in your app's build.gradle file, reset the plugin's default list of ABIs and include only the supported ABIs you want, as shown below:

 
 
... splits { abi { ... reset() include "x86", "armeabi-v7a", "armeabi-v8a", "x86_64" } }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值