2016-07-07 58 views
1

無法上傳多個apk,多個CPU。 每個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" 
     } 

    } 
} 

回答

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 
    } 
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 
     } 
    }