3

I'm finally migrating from Eclipse to Android Studio and can't even connect a little module.

Here's the only file in resources - as you can see by a screenshot, there is no error there

enter image description here

But in the class where it is needed 'R' is not resolved. So I'm confused - there is not too much to look into

enter image description here

There are problems in App's module as I didn't hook all the libraries yet, but no obvious problem in 'dragsortlib' module. I cleaned, rebuilt project but this didn't help.

manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mobeta.android.dslv"
    android:versionCode="4"
    android:versionName="0.6.1">
    <uses-sdk android:targetSdkVersion="7"
        android:minSdkVersion="7" />
</manifest>

gradle :

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile files('libs/android-support-v4.jar')
    testCompile 'junit:junit:4.12'
}
Vlad Alexeev
  • 2,072
  • 6
  • 29
  • 59

3 Answers3

2

Click on Build -> Rebuild Project and then click Tools -> Android -> Sync Project with Gradle Files.

You may refer here

Community
  • 1
  • 1
AI.
  • 934
  • 2
  • 14
  • 30
1
  1. First check the import of R file
  2. Delete build folder under app manually and Build project again.
  3. Check your xml files. R.java is not generated if you have errors in your xml file.
  4. Lastly update your build tools.
Rajesh Gosemath
  • 1,812
  • 1
  • 17
  • 31
0

I would like to make clear that this Error occurs while there is any issue in your res folder and it is not allowing to auto generate resource id in R.Java file. So look it carefully in your resource folder and manifest what causes this error.

It would be a little mistake causing this error, Once you find that mistake you can easily resolve this error, But most of the case you need to Clean Project or Invalidate Cache and Restart will work after resolving issue.

Hope this will work.

Zafar Imam
  • 319
  • 3
  • 11