在Android Studio中运行应用时出错

时间:2016-06-04 01:53:35

标签: android android-studio

代码:

/**
* Automatically generated file. DO NOT MODIFY
*/
package com.example.android.sunshine.app;

public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID =    "com.example.android.sunshine.app";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
// Fields from build type: debug
public static final String OPEN_WEATHER_MAP_API_KEY =  4ae9a193e3ce7970984625be19352fd6;
}

我认为错误可能在行

中发生
public static final String OPEN_WEATHER_MAP_API_KEY =  4ae9a193e3ce7970984625be19352fd6;

一定是

public static final String OPEN_WEATHER_MAP_API_KEY =  "4ae9a193e3ce7970984625be19352fd6";

但是当我更改代码并运行时,Android Studio会自动更改为代码。

1 个答案:

答案 0 :(得分:0)

build.gradle更新为:

 buildTypes.each {
     it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', "\"4ae9a193e3ce7970984625be19352fd6\""
 }