-1

My application was working fine in Android Studio but when i added Library of google map.Showing an error.

package com.iremember.kiet;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap; //no error
import info.androidhive.slidingmenu.R;// Cannot Resolve symbol R (when added library of google map)

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 18
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "info.androidhive.slidingmenu"
        minSdkVersion 11
        targetSdkVersion 17
    }

    buildTypes {

        debug {
            debuggable true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
}

the error " Cannot Resolve symbol R" comming after i added google lib

Usman Asif
  • 111
  • 1
  • 1
  • 9

2 Answers2

0

Step 1(optional but helpful):

This is Java and not C or C++, stop trying to memorize the imports.

You are using Android Studio which is based off Intellij, turn on Optimize Imports: https://www.jetbrains.com/idea/help/optimizing-imports.html

Step 2:

Sync and Clean your project.

Step 3:

Without a doubt, you need to target the latest libs, get these from your SDK Manager:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22 // <-- was 18
    buildToolsVersion "22.0.0" // <-- was 21.1.2

    defaultConfig {
        applicationId "info.androidhive.slidingmenu"
        minSdkVersion 11
        targetSdkVersion 22 // <-- was 17
    }

    buildTypes {
                 // <-- debug is debuggable by default
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:22.0.0' // <-- was 18
    compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.0.3
    compile 'com.google.android.gms:play-services:6.5.87'
}
Community
  • 1
  • 1
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
0

I have a same problem and fix it with "sync project with Gradle files"

anopid
  • 139
  • 1
  • 5