Search code examples
javaandroidbuild.gradleandroid-2.2-froyo

Can not resolve symbol R and build.gradle error


I began to program with Android and so I downloaded Android Studio 2.1.3 and Android SDK and jdk 1.8.0_60 the Gradle version is 2.14.1. I want to program with Android 2.2. In my class called GameView is the problem:

bmp = BitmapFactory.decodeResource(getResources(),
                R.mipmap.ic_launcher);

it can not resolve symbol R

I read that I can solve the problem in these ways:

BUILD -> Clean Project

Tools -> Android -> Sync Project with Gradle Files

File -> Invalidate Caches / Restart

Nothing helped so I tried to changed the Versions in build.gradle(Module: app). I do not really know which Versions I need to program for Android 2.2. Please help me or do you know any other solution to fix that problem?

Thanks!


Solution

  • In my case the solution was to put the minSdkVersion from 8 to 9.

    I also changed the versions in build.gradle:

    compileSdkVersion 24
        buildToolsVersion "24.0.1"
    
        defaultConfig {
            applicationId "com.panjutorials.lazypudding"
            minSdkVersion 9
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
    

    The only disadvantage is that I program with Android Nougat now but that's okay.

    Good luck for everybody who has a similar problem.