我尝试将facebook添加到我的gradle文件中,如下所示:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
repositories { mavenCentral() }
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.3"
defaultConfig {
applicationId "com.beerportfolio.beerportfoliopro"
minSdkVersion 15
targetSdkVersion 21
versionCode 59
versionName "4.6.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile "com.android.support:appcompat-v7:21.0.+"
compile 'com.google.android.gms:play-services:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
在Facebook的指示中也说:
针对Android开发人员的说明如果您在该版本上使用ProGuard 要构建您的应用,您必须将此代码段添加到您的应用中 proguard-project.txt配置文件:
-keep class com.facebook。** {*; } -keepattributes Signature这些标志用于保存泛型签名并保留用于反射的类型信息。都 SDK是在Android中正常运行所必需的 应用
所以在我的专业保护文件中(我可能在错误的文件中完成了这个...):
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Mike/Documents/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.facebook.** { *; }
-keepattributes Signature
因此,当我尝试构建我的项目时,它会抛出此错误:
当我点击它并尝试修复它时,我得到了这个:
答案 0 :(得分:1)
只需从SDK Manager安装最新版本的 Android SDK Build-tools ,我相信它现在 22 。
然后在build.gradle中更改此行
buildToolsVersion "21.1.3"
到正确的版本。
buildToolsVersion "22"
答案 1 :(得分:0)
您的build.gradle
文件指定了21.1.3的构建工具版本,该版本不是有效版本。
此时(2015年11月3日),最新的构建工具版本为22,因此请更改此行
buildToolsVersion "21.1.3"
到
buildToolsVersion "22.0.0"
它会起作用。