【问题标题】:build.gradle to support Google Play services?build.gradle 支持 Google Play 服务?
【发布时间】:2014-12-24 14:46:57
【问题描述】:

我是 Android/Java 编程新手,但在 Play 商店中有一个完整的 Android 应用程序。所以我想将 Google Cloud Messaging 添加到我的应用程序中,而那时我遇到了麻烦。各种教程告诉我获取 Google Play 服务 SDK 和 Google 存储库。现在,当我尝试构建时,我得到了 101 个错误,我认为与我的一个或多个 build.gradle 文件有关。我花了几个小时试图解决这个问题。任何帮助将不胜感激!

这是我看到的消息的顶部:

错误:任务 ':lib:processReleaseResources' 执行失败。

com.android.ide.common.internal.LoggedErrorException:无法运行命令: /Applications/Android Studio.app/sdk/build-tools/19.1.0/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-19/android.jar -M /Users/scott/Documents/development/Android HVB/lib/build/bundles/release/AndroidManifest.xml -S /Users/scott/Documents/development/Android HVB/lib/build/res/all/release -A /Users /scott/Documents/development/Android HVB/lib/build/bundles/release/assets -m -J /Users/scott/Documents/development/Android HVB/lib/build/source/r/release --non-constant- id --output-text-symbols /Users/scott/Documents/development/Android HVB/lib/build/bundles/release

这里是“app”build.gradle 文件:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.1'

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 14
        versionName "1.3a"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:6.5.+'
    compile project(':lib')
}

【问题讨论】:

  • 使用这个编译 'com.google.android.gms:play-services:5.0.89' 代替 6.5.+
  • 你解决了吗?

标签: android gradle


【解决方案1】:

我描述了这个HERE

刚刚更新了你的 build.gradle

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
     buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }

请更新您的清单。

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxxxx"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="19" />

【讨论】:

  • 我将“runProguard false”更改为“minifyEnabled false”,现在看到以下内容(共 7 行):上午 12:12:08 Gradle 调用在 4 秒 12 内成功完成,出现 1 个错误:12:11 上午 Gradle 'Android HVB' 项目刷新失败:构建脚本错误,发现不支持的 Gradle DSL 方法:'minifyEnabled()'!可能的原因可能是:-您使用的是缺少该方法的 Gradle 版本-您没有应用提供该方法的 Gradle 插件-或者构建脚本中有错误
  • 谢谢。我在依赖项 {} 的第一行添加了“classpath 'com.android.tools.build:gradle:0.8.+'” 并得到了同样的错误。你的意思是我应该这样做吗?
  • 相同的结果。我烦了。去睡觉了。
  • 在我的应用程序中,我使用 gms 版本:再试一次。编译 'com.google.android.gms:play-services:5.0.89'
  • 使用这个类路径'com.android.tools.build:gradle:0.14.+'
猜你喜欢
  • 2013-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-18
相关资源
最近更新 更多