Cannot resolve symbol c882c94be45fff9d16a1cf845fc16ec5

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).

The build.gradle file is as follows:

  • RecyclerView scrolling on insert
  • TabLayout (Android Design Library) Text Color
  • can i edit the text of sign in button on google?
  • Failed to initialize display event receiver
  • is it possible release an updated app by signing it with a different certificate than the one originally used
  • Paho MQTT Android service wake up activity
  • 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'
    }
    

    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;
    

    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";
    

    or

    public static final String OPEN_WEATHER_MAP_API_KEY = 'c882c94be45fff9d16a1cf845fc16ec5';
    

    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.

    Regards.

    Related posts:

    Using Dropbox API to upload a file with Android
    Delete my application programmatically (Android)
    difference between android looper and executor thread pool
    Piracy, piracy, piracy. What can I do?
    Handling and Mitigating IllegalStateException (“failure saving state: active $Fragment has...
    Mobile app: how to show the OTP my app sends in a popup without leaving my app?
  • Detect proximity using Bluetooth LE “Proximity” profile Android
  • How to wake up Android Wear when it is in sleep mode?
  • Communications link failure Last packet sent to the server was 1 ms ago.
  • Implementing C#-like events in Android/Java
  • Android Studio is slow (how to speed up)?
  • Loader delivers result to wrong fragment
  • 2 Solutions collect form web for “Cannot resolve symbol c882c94be45fff9d16a1cf845fc16ec5”

    Change

     buildTypes.each {
         it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'c882c94be45fff9d16a1cf845fc16ec5'
     }
    

    with

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

    this way OPEN_WEATHER_MAP_API_KEY should be escaped correctly

        "\"c882c94be45fff9d16a1cf845fc16ec5\""
    

    This is the correct syntax for making changes to the BuildTypes container.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.