1

我正在基于 ABI 构建发布 apk,因为要在Play 商店上发布的 apk 大小。

所以我开始为ABI = armeabi-v7a构建 apk,然后构建ABI = x86 和 ABI = areambi

所以我的gradle看起来像这样

应用程序等级

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.package"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
    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 "armeabi-v7a"

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

我懂了

所以我的问题

  1. 我需要versionCode 1对每个 ABI 进行更改,因此我应该使用哪个 ABI 的版本代码。
4

2 回答 2

1

我必须进行 2 个不同的构建

构建 1:用于 armeabi-v7a

versionCode 21614001
splits {
    abi {
        enable true
        reset()
        include "armeabi-v7a"
        universalApk false
    }
}

构建 2:用于 x86

versionCode 61614001
splits {
    abi {
        enable true
        reset()
        include "x86"
        universalApk false
    }
}

根据支持的 abi 添加了本机库。

发布后,apk Build 1 和 Build 2 将一起显示支持的设备。

于 2017-11-24T12:30:01.533 回答
1
productFlavors{  

    arm{  
        ndk{  
            abiFilters "arm64-v8a" , "armeabi"  , "armeabi-v7a"  
        }  
    }  
    x86{  
        ndk{  
            abiFilters "x86" , "x86_64"  
        }  
    }  
}  
于 2017-11-15T08:09:56.703 回答