[英]API Key configuration android
In my app I am going to use The Movies DB API to get most popular movies posters. 在我的应用程序中,我将使用The Movies DB API来获取最受欢迎的电影海报。
Kindly need your help with the below issue: 请在以下问题上为您提供帮助:
every time I try to run my app I get these errors 每次我尝试运行我的应用程序时,都会出现这些错误
Error:(14, 77) error: expected 错误:(14,77)错误:预期
Error:(14, 53) error: ';' 错误:(14,53)错误:';' expected
预期
Error:(14, 45) error: malformed floating point literal 错误:(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'
}
and here is where I get the error in the buildconfig.java: 这是我在buildconfig.java中得到错误的地方:
at the top here there is a line saying "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
}
You should use backslashes, change 您应该使用反斜杠,更改
it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'
to 至
it.buildConfigField 'String', 'THE_MOVIE_DB', "\"967888xxxxxxxxx\""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.