如何使用Gradle生成具有不同AndroidManifest.xml的apks?

时间:2013-09-14 15:42:05

标签: android gradle

我写的build.gradle如下:

sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
         hip {
            manifest.srcFile 'hip/AndroidManifest.xml'
}
        instrumentTest.setRoot('tests')

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

但是我只能找到主要的apks而不是hip ..

1 个答案:

答案 0 :(得分:0)

您必须定义产品口味:

android {
  ...
  productFlavors {
    hip {
        manifest.srcFile 'hip/AndroidManifest.xml'
    }

    main {
        manifest.srcFile '<where you put the other one>/AndroidManifest.xml'
    }
}