从多个cpu上传多个apk?

时间:2016-07-07 16:58:15

标签: android google-play

无法上传多个apk,用于多个cpu。 每个apk必须有不同的版本吗? 有必要添加和

versionName '2.29.011.Sonia'
    versionCode 32

来自每个apk?

我的配置。

  compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
    applicationId 'xx.yyy.zzzzzz'
    minSdkVersion 19
    targetSdkVersion 24 //21 ca sa nu mai dea errorare
    versionName '2.29.011.Sonia'
    versionCode 32
    // Enabling multidex support.
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    // ndk {
    //    abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
    //}
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    signingConfig signingConfigs.config1
}

productFlavors {
    cpu_86 {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 22
        ndk {
            abiFilters "x86"
        }

    }
    armeabi_cpu {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "armeabi"
        }

    }
    armeabi_v7a_cpu {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "armeabi-v7a"
        }

    }
    arm64_v8a_cpu {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "arm64-v8a"
        }

    }
    x86_64_cpu {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "x86_64"
        }

    }
}

2 个答案:

答案 0 :(得分:1)

已从更改minSdkVersion修复并添加versionCode

代码:

    productFlavors {
    cpu_86 {
        minSdkVersion 17
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "x86"
        }
        versionCode 46
        versionName '2.41.011.Sonia'
    }
    armeabi_cpu {
        minSdkVersion 18
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "armeabi"
        }
        versionCode 47
        versionName '2.42.011.Sonia'
    }
    armeabi_v7a_cpu {
        minSdkVersion 19
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "armeabi-v7a"
        }
        versionCode 48
        versionName '2.43.011.Sonia'
    }
    x86_64_cpu {
        minSdkVersion 20
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "x86_64"
        }
        versionCode 49
        versionName '2.44.011.Sonia'
    }
    arm64_v8a_cpu {
        minSdkVersion 21
        signingConfig signingConfigs.config1
        targetSdkVersion 24
        ndk {
            abiFilters "arm64-v8a"
        }
        versionCode 50
        versionName '2.45.011.Sonia'
        multiDexEnabled true
    }

答案 1 :(得分:0)

试试这个:

  android {

        // To create different apk per abi
        splits {
            abi {
                enable true
                reset()
                include 'armeabi', 'armeabi-v7a', 'x86'
                universalApk true
            }
        }
    }

    import com.android.build.OutputFile

    // Map for the version code
    ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'x86': 3]
    android.applicationVariants.all { variant ->

        // assign different version code for each output
        variant.outputs.each { output ->
            int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
            output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode
        }
    }