Khaled Almanea
Khaled Almanea

Reputation: 198

API Key configuration android

In my app I am going to use The Movies DB API to get most popular movies posters.

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

Error:(14, 53) error: ';' expected

Error:(14, 45) error: malformed floating point literal

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:

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
}

Upvotes: 1

Views: 783

Answers (1)

Mehdi Sakout
Mehdi Sakout

Reputation: 783

You should use backslashes, change

it.buildConfigField 'String', 'THE_MOVIE_DB', '967888xxxxxxxxx'

to

it.buildConfigField 'String', 'THE_MOVIE_DB', "\"967888xxxxxxxxx\""

Upvotes: 6

Related Questions