无法解析符号c882c94be45fff9d16a1cf845fc16ec5 [英] Cannot resolve symbol c882c94be45fff9d16a1cf845fc16ec5
问题描述
我是一个新的开发探索了Android的世界。我目前正在通过Udacity教程创建阳光的应用程序。在为了得到openweathermap我必须从我的帐户添加API密钥我到生成的URL月底的数据片段活动类。有一个在片段活动调用BuildConfig.java(点击查看调用BuildConfig.java这是六号线为String apiKey的一部分)。
I am a new developer exploring the world of Android. I am currently working through the Udacity tutorials for creating the Sunshine app. In the fragment activity class in order to get data from openweathermap I must add the API key I got from my account to the end of the generated URL. There is a call to BuildConfig.java in the Fragment activity (click to see the call to BuildConfig.java which is on the 6th line as part of String apiKey).
该build.gradle文件如下:
The build.gradle file is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.android.sunshine.app"
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'c882c94be45fff9d16a1cf845fc16ec5'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
}
在buildTypes.each it.buildConfigField被称为与字符串','OPEN_WEATHER_MAP_API_KEY','c882c94be45fff9d16a1cf845fc16ec5造成
in buildTypes.each it.buildConfigField is called with 'String', 'OPEN_WEATHER_MAP_API_KEY', 'c882c94be45fff9d16a1cf845fc16ec5' resulting in
public static final String OPEN_WEATHER_MAP_API_KEY = c882c94be45fff9d16a1cf845fc16ec5;
正在BuildConfig.java产生的,不过,我不断收到此错误: 不能解析符号(点击查看错误信息和BuildConfig.java文件) 我不明白为什么字符串OPEN_WEATHER_MAP_API_KEY会自动被创建为只是一组字母和数字没有他们周围的报价,但如果我编辑code阅读:
being generated in BuildConfig.java, however I keep getting this error: Cannot Resolve Symbol (click to see error message and BuildConfig.java file) I do not understand why the String OPEN_WEATHER_MAP_API_KEY is automatically being created as just a group of letters and numbers without quotes around them, but if I edit the code to read:
public static final String OPEN_WEATHER_MAP_API_KEY = "c882c94be45fff9d16a1cf845fc16ec5";
或
public static final String OPEN_WEATHER_MAP_API_KEY = 'c882c94be45fff9d16a1cf845fc16ec5';
在BuildConfig.java自动改变自己。 我不知道我做错了,我查了许多Udacity的视频时并没有对这个问题的任何信息。请让我知道,如果你知道如何解决这个问题。
the BuildConfig.java automatically changes itself. I am not sure what I am doing wrong and I checked many of the Udacity videos which did not have any information about this issue. Please let me know if you know how to fix this.
问候。
推荐答案
修改
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'c882c94be45fff9d16a1cf845fc16ec5'
}
与
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', "\"c882c94be45fff9d16a1cf845fc16ec5\""
}
这样 OPEN_WEATHER_MAP_API_KEY
应正确转义
这篇关于无法解析符号c882c94be45fff9d16a1cf845fc16ec5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!