根据productFlavor设置applicationIdSuffix

Nim*_*a G 5 android gradle build.gradle

我们有2个productFlavors(testServer,liveServer)和2个构建类型(调试,发布).

由于现有的API密钥,我必须根据buildType + productFlavor追加包名.

例如:

buildTypes {
  debug {
   applicationIdSuffix '.dbg' + (testServer ? '.test' : '.live')
  }

  release {
   applicationidSuffix '' + (testServer ? '.test')
  }  
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?怎么样?

Mar*_*ira 7

productFlavors {
    testServer {
        applicationId = "com.example.my.pkg.test"
    }
    liveServer {
        applicationId = "com.example.my.pkg.live"
    }
}

buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }
}
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看有关应用程序ID 的Android文档.