2016-01-21 78 views
7

我使用compile project(':pickphotos')來包含名爲pickphotos的庫。我在圖書館中的R是紅色的,但我可以通常構建並運行應用程序

Pickphotos中的R雖然是紅色,但我有me.crosswall.photo.pick.R.I可以正常構建和運行應用程序。

enter image description here

當我使用Alt + Enter鍵,它示出了一些解決方案:

enter image description here

當我使用在pickphotos移動 'R',它顯示了一些R:

enter image description here

但是,如果我選擇me.crosswall.photo.pick.R,我會在我的nex中得到重複的R錯誤建立。

下面是pickphotos的的build.gradle:

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 { 

} 

我也能找到它的應用程序/建設/生成/源/ R:

enter image description here

沒有標記爲項目在Android Studio中的菜單中:

enter image description here

+0

有時這發生在xml文件中有錯誤時 檢查,然後清理項目 –

+0

我認爲,您應該將生成源文件夾標記爲Android Studio中的生成源。 –

+0

@ Delta7我清理項目並刪除構建文件夾的時間。 –

回答

1

我終於重新擁抱了它。

Just Make Project。

R是在製作項目時創建的。

我認爲當我們運行項目或生成項目時,Android Studio由於某種原因沒有生成項目。

0

去建設>重建項目和/或清潔項目似乎是第一次嘗試修復任何mindboggling紅色錯誤。最好做到這一點,然後花45分鐘盯着代碼試圖找出什麼是錯誤的時候,答案竟然是'沒有'...

相關問題