在android中为不同的风味创建单独的apk

Sim*_*der 5 android build buildconfiguration apk android-productflavors

我使用 build.gradle(app) 来创建不同风格的 apk。但是安装不同风格的同一个 apk 会覆盖前一个。我想创建不同的 apk 以同时在同一设备上运行。我想使用不同的 appicon 创建不同的 apk,这些 appicon 可以安装在同一设备上并同时运行。任何链接或教程或直接帮助表示赞赏。

提前致谢。

Mur*_*ain 4

更改风味的PackageName

示例 Gradle 文件

apply plugin: 'com.android.application'

android {

    lintOptions {
        abortOnError false
    }


    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
    }

    buildTypes {
        debug {
            minifyEnabled false
            zipAlignEnabled true
        }
        release {
            minifyEnabled true
            zipAlignEnabled true
        }
    }
    productFlavors {
        Flavor1 {
            applicationId "com.falvor.one" //This is where you change the package name
        }
        Flavor2 {
            applicationId "com.falvor.two"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Android 中的风味层次结构

- src/main/java
- src/flavor1
--------------Java
----------------Your java files
--------------res
----------------Drawable
Run Code Online (Sandbox Code Playgroud)
  • src/flavor2/java

如需更多了解,请点击此链接