Gardle无法建立同步

时间:2017-10-05 07:34:25

标签: android android-gradle build.gradle gradle-plugin crashlytics-android

我正在尝试下面的教程,以使我的api密钥安全

http://www.techjini.com/blog/securing-api-key-and-secret-key-in-android/

但是当我点击“立即同步”时,我会收到以下错误

Error:org.gradle.api.GradleException: Crashlytics Developer Tools error.
Error:com.crashlytics.tools.android.exception.PluginException: Crashlytics Developer Tools error.
Error:java.lang.IllegalArgumentException: Crashlytics found an invalid API key: "xxxxxMYFABRICKEYxxxxx".

gradle.properties

####################
#Fabric
FabricKey=my fabric key
####################

Gradle文件

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
def FABRIC_KEY = '"' + FabricKey + '"' ?: '"Error occurs..."'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"

    defaultConfig {
        //... other info

        manifestPlaceholders = [
                FABRIC_KEY : FABRIC_KEY
        ]
    }
    }

的AndroidManifest.xml

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="${FABRIC_KEY}" />

1 个答案:

答案 0 :(得分:1)

双引号是罪魁祸首'""'

替换

def FABRIC_KEY = '"' + FabricKey + '"' ?: '"Error occurs..."'

通过

def FABRIC_KEY = FabricKey ?: '"Error occurs..."'

感谢@Selvin的评论