【问题标题】:Migrating to GCM breaks the build process迁移到 GCM 会破坏构建过程
【发布时间】:2015-07-14 13:57:50
【问题描述】:

我正在尝试迁移我的应用并添加类路径 'com.google.gms:google-services:1.3.0-beta1' 会破坏构建:

这是我的顶级 gradle.build:

// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'com.github.hamsterksu:android-appversion-gradle-plugin:1.2.+'
        classpath 'com.google.gms:google-services:1.3.0-beta1'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
    }
}

这样做会导致构建失败并显示以下消息:

出了什么问题: 发现任务':app:zipalignAppDebug'的配置有问题。

文件 为属性“inputFile”指定的“/path../outputs/apk/app-app-debug-unaligned.apk”不存在。

【问题讨论】:

  • 确保您拥有最新的 Android gradle 插件 com.android.tools.build:gradle:1.2.3 并运行 gradlew clean
  • com.android.tools.build:gradle:1.2.3com.android.tools.build:gradle:1.3.0-beta1 有同样的问题
  • 我认为您使用了错误的插件。删除该服务插件并添加此依赖项:com.google.android.gms:play-services-gcm:7.5.0developers.google.com/android/guides/setup.
  • 我的项目 build.gradle 中有 play-services-gcm。以上是最顶层的 gradle 文件。 google-services 插件应该读取google-services.json 并使用默认名称创建字符串值。这是他们作为强制性步骤添加的“方便”的东西:developers.google.com/cloud-messaging/android/client 如果我能找到我需要使用的默认名称,我会从我的构建中删除它并硬编码这些值。这越来越荒谬了。

标签: android google-cloud-messaging google-play-services


【解决方案1】:

我也发现了这些问题,我发现它是因为我使用了 22 buildtoolsversion

将您的 buildToolsVersion 更改为版本 23,它会再次工作

打开 app/build.gradle

android {
  compileSdkVersion 22
  buildToolsVersion "23.0.0 rc3"

  defaultConfig {
    applicationId "packagename.id"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode appVersionCode
    versionName appVersionName
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-10
    • 2016-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多