在com.android.build.gradle.AppExtension_Decorated上找不到属性'xxxx' [英] Could not find property 'xxxx' on com.android.build.gradle.AppExtension_Decorated

查看:1087
本文介绍了在com.android.build.gradle.AppExtension_Decorated上找不到属性'xxxx'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  buildTypes.each {
it

在我将这些行添加到我的gradle文件后出现此错误: .buildConfigField'String','OPEN_WEATHER_MAP_API_KEY',MyOpenWeatherMapApiKey
}

然后日志显示:

 在com.android.build.gradle.AppExtension_Decorated@c3b784 

Google搜索到的解决方案无法解决我的问题。请告诉我我错了什么地方?

解决方案

由于您使用的是 String 您必须使用以下语法:

  buildConfigFieldString,OPEN_WEATHER_MAP_API_KEY,\XXXXX-XXXXX- XXX \

最后一个参数必须是字符串

否则,您可以使用以下内容:

  resValuestring,OPEN_WEATHER_MAP_API_KEY, \\XXXXX-XXXXX-XXX \

第一种情况会在您的 BuildConfig 文件。

第二种情况生成一个字符串资源值,可以使用 @ string / OPEN_WEATHER_MAP_API_KEY 注释。


I got this error after I added these lines to my gradle file:

buildTypes.each {
        it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey
    }

then the log show:

Could not find property 'MyOpenWeatherMapApiKey' on com.android.build.gradle.AppExtension_Decorated@c3b784

The solutions on google that I searched cannot solve my problem. Please show me where I was wrong?

解决方案

Since you are using a String you have to use this syntax:

buildConfigField "String" , "OPEN_WEATHER_MAP_API_KEY" ,  "\"XXXXX-XXXXX-XXX\""

The last parameter has to be a String

Otherwise you can use something like this:

resValue "string", "OPEN_WEATHER_MAP_API_KEY", "\"XXXXX-XXXXX-XXX\""

The first case generates a constants iin your BuildConfig file.
The second case generates a string resource value that can be accessed using the @string/OPEN_WEATHER_MAP_API_KEY annotation.

这篇关于在com.android.build.gradle.AppExtension_Decorated上找不到属性'xxxx'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆