Reputation: 6251
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.
When I use Alt+Enter , it shows some solution:
When I use Move 'R' in pickphotos, it shows some R:
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:
There is no Mark as item in menu in Android Studio:
Upvotes: 7
Views: 410
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
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