Android:buildTypes applicationIdSuffix错误

Jon*_*Jon 5 android build.gradle android-gradle-plugin android-build-type android-gradle-2.0

我想设置一个项目来构建两个可以安装在同一设备上的不同apks - 其中一个是生产apk,第二个是调试apk.为此,我在build.gradle中定义了:

buildTypes {
        release {

        }

        debug {
            applicationIdSuffix = ".debug"
        }

    }
Run Code Online (Sandbox Code Playgroud)

但是当我尝试同步gradle时,我得到错误:

Error:org.gradle.api.GradleException: No matching client found for package name 'mypkg.debug'
Run Code Online (Sandbox Code Playgroud)

除了build.gradle的buildTypes部分之外,我还应该做些什么来使其正常工作?

小智 8

您需要为每种构建风格提供google-service.json.在您的情况下,您需要一个调试.

使用新包名称(原始包名称+ .debug)生成一个新包.然后将json放入app/src/debug /.

  • 复制现有的“ google-service.json”,然后将“ package_name”修改为“ com.foo.bar.debug”就可以了。https://developers.google.com/android/guides/google-services-plugin#adding_the_json_file (3认同)