API 关键配置 android
API Key configuration android
在我的应用程序中,我将使用 The Movies DB API 来获取最受欢迎的电影海报。
以下问题需要您的帮助:
每次我尝试 运行 我的应用程序时都会收到这些错误
错误:(14, 77) 错误:预期
错误:(14、53) 错误:“;”预计
错误:(14, 45) 错误:格式错误的浮点文字
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.almaneakhaled.popularmoviesapp2"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildTypes.each {
it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
}
这里是我在 buildconfig.java:
中得到错误的地方
在顶部有一行说 "files under the build folder are generated and should not be edited"
package com.almaneakhaled.popularmoviesapp2;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.almaneakhaled.popularmoviesapp2";
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 THE_MOVIE_DB = 967888xxxxxxxxx;// this line is causing the issue
}
你应该使用反斜杠,改变
it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'
至
it.buildConfigField 'String', 'THE_MOVIE_DB', "\"967888xxxxxxxxx\""
在我的应用程序中,我将使用 The Movies DB API 来获取最受欢迎的电影海报。
以下问题需要您的帮助:
每次我尝试 运行 我的应用程序时都会收到这些错误
错误:(14, 77) 错误:预期
错误:(14、53) 错误:“;”预计
错误:(14, 45) 错误:格式错误的浮点文字
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.almaneakhaled.popularmoviesapp2"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildTypes.each {
it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
}
这里是我在 buildconfig.java:
中得到错误的地方在顶部有一行说 "files under the build folder are generated and should not be edited"
package com.almaneakhaled.popularmoviesapp2;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.almaneakhaled.popularmoviesapp2";
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 THE_MOVIE_DB = 967888xxxxxxxxx;// this line is causing the issue
}
你应该使用反斜杠,改变
it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'
至
it.buildConfigField 'String', 'THE_MOVIE_DB', "\"967888xxxxxxxxx\""