-1

我想下面的教程,让我的API密钥安全Gardle失败的基础上同步

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 file

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

'$ {...}'不是'{$ ...}'请使用官方文档不是一些有问题的质量教程 – Selvin

+0

但我仍然得到相同的错误 – VVB

+0

* Gardle *很奇怪... – Vucko

回答

1

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

替换

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

通过

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

谢谢@Selvin的评论