android - 如何为特定CPU架构创建apk文件

标签 android android-studio android-gradle-plugin apk cpu-architecture

我已经知道 gradle 上提供的 split 选项,它可以为不同的 cpu 架构生成多个 apk。

如何生成仅包含armeabi-v7a和x86架构的apk?

最佳答案

Step 1: Add the class path dependency to the project level build.gradle file.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:3.7.1"
    }
}

Step 2: Apply the realm-android plugin to the top of the application level build.gradle file.

apply plugin: 'realm-android'

Step3: Add this to the application’s build.gradle:

realm {
  syncEnabled = true;
}

Step4:Add this to the application’s build.gradle:
android{
   defaultConfig{
       applicatioId "com.android.abi.myapplication"
       minSdkVersion 16
       targetSdkVersion 25
       ndk{
           abiFilters "armeabi-v7a", "x86" // Add only required cpu architectures here
       }
   }
}

然后同步gradle并构建apk,将仅找到armeabi-v7a和x86的库文件。

关于android - 如何为特定CPU架构创建apk文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40213925/

相关文章:

java - 从maven central获取bot-java lib的方法是什么

Android db文件被复制但无法打开

android:显示错误的方法

android - 什么是 Eclipse Andmore 项目?

android - Android Studio 无法识别默认配置

java - 从 kotlin 引用时, Unresolved Java 文件引用不同风格

Android Studio 4.0.1 和 IntelliJ 2020.2 IDE 之间的 Gradle 兼容性

Android Studio : cannot resolve some symbol and method

java - 来自 google-services.json 的 AndroidManifest.xml 中的谷歌地图键

android - AndroidStudio 4+ 上的语言级别 Java 8 (Retrolambda)?