tiny sunlight
tiny sunlight

Reputation: 6251

My R in library is red but I can build and run app normally

I use compile project(':pickphotos') to include a library named pickphotos.

The R in pickphotos is red though I have me.crosswall.photo.pick.R.I can build and run the app normally.

enter image description here

When I use Alt+Enter , it shows some solution:

enter image description here

When I use Move 'R' in pickphotos, it shows some R:

enter image description here

But if I pick me.crosswall.photo.pick.R,I will get repeat R error in my next build.

Below is the build.gradle of pickphotos:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

dependencies {

}

I can also find it app/build/generated/source/r:

enter image description here

There is no Mark as item in menu in Android Studio:

enter image description here

Upvotes: 7

Views: 410

Answers (2)

mmmartinnn
mmmartinnn

Reputation: 407

Going to Build > Rebuild Project and/or Clean Project seems to be the goto first attempt at fixing any mindboggling red errors. Better to do that then spend 45 minutes staring at code trying to figure out what's wrong when the answer turns out to be 'nothing'...

Upvotes: 0

tiny sunlight
tiny sunlight

Reputation: 6251

I finally resloved it.

Just Make Project.

R is created when Make Project.

I think when we Run Project or Build Project,Android Studio doesn't Make Project for some reason.

Upvotes: 1

Related Questions