生成 android 个 x86 版本的 App Bundle

Generate android App Bundle with x86 version

我使用 flutter 开发我的应用程序。但是,要生成应用程序包并将其上传到控制台,我使用 Android Studio(构建 -> 生成签名的 Apk)。

在 flutter 中,我可以选择通过 flutter 构建命令为三种架构(arm、arm64 和 x86(64?))生成三个不同的 apk。但是,当我从 Android Studio 生成签名的应用程序包并将其上传到控制台时,我只得到两个构建变体或 abi(arm64-v8a、armeabi-v7a)。如何让我的应用程序包包含 x86 abi?

补充:我只使用Android Studio生成App Bundle。我使用 VS Code 编写这些应用程序。

编辑:module/App 级别 build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.spayro.spayroshop"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

请将此代码放入您的 gradle:

ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'

例子

    android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

目前不支持 x86 架构。

https://flutter.dev/docs/deployment/android#what-are-the-supported-target-architectures