0

After 6h spent trying to fix this by myself, AS is driving me crazy. Everything was fine yesterday and today it can't resolve any of the support libs nor the R symbols.

enter image description here

I tried everthing, including all the suggested fixes I found on StackOverflow. No need to tell me to have a look a this post, I already have and none of the solutions work.

Here's what I tried so far :

  • rebuilding / cleaning the project (many times...),
  • synchronising the project with Gradle Files,
  • check that the support lib is up-to-date in the SDK Manager,
  • invalide Caches / restart AS,
  • delete the .idea folder and the .iml files of my project, and re-importing it in AS,
  • update AS from 0.8.11 to 0.9,
  • eventually I ended up uninstalling AS and reinstalling it from scratch

And none of this fixed my issue...

Something really weird is that I also tried to create a whole new project from scratch and to copy/paste all my classes & resources from my corrupted project to this new one. And it worked for a while (~10 min), until it eventually became corrupted the same way, without any apparent reason.

Moreover, no idea if it's relevant, but when I type "ViewPager" in AndroidStudio and hit CTRL-SPACE, it doesn't suggest me the "android.support.v4.view.ViewPager" class. But if I hit CTRL-SPACE 3 times in a row, it DOES suggest it. So I guess that means that it's able to find the support lib somewhere but not to use it?

Here's my build.gradle :

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.mathieumaree.library"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:support-v13:21.0.0'
}

Please, help me, otherwise I'm gonna break my computer soon.

Thanks in advance,

Mathieu

EDIT 1 :

I forgot to mention that this occurs only in one of my projects. The others seem to be fine (at least for now).

EDIT 2 :

I also forgot to mention that my project is composed of an application project plus a library module inside it. So here is the app's build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.mathieumaree.materialheaderviewpager"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library')
    compile 'com.android.support:support-v13:21.0.0'
    compile 'com.android.support:appcompat-v7:21.0.0'
}

The app Manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mathieumaree.materialheaderviewpager" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.mathieumaree.materialheaderviewpager.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

The library manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mathieumaree.library">

    <application android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/AppTheme">

    </application>

</manifest>

The main settings.gradle :

include ':app', ':library'

And the main build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

EDIT 3 :

After trying once more to delete all .idea folers & *.iml files and reloading my project, I noticed that AndroidStudio displayed an error at openning :

Accessing invalid virtual file: file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21; original:582; found:-: Accessing invalid virtual file: file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21; original:582; found:-

I'm pretty sure it means it's looking for the SDK to yet another location (AppData/Local...android-21). What I don't understand is :

  • there's no SDK folder at this location
  • the SDK path indicated in the Project Structure is not this one

Any idea what all this means?

Community
  • 1
  • 1
MathieuMaree
  • 7,453
  • 6
  • 26
  • 31
  • Seems like you've tried all the obvious things. Where is your SDK folder located? – stkent Nov 03 '14 at 13:44
  • It used to be in my C:/Program Files/Android/AndroidStudio folder. Then this issue appeared, I upgraded AndroidStudio and had to move my SDK to ~/MyAndroidStudioFolder/SDK (I just followed [this official blog post](http://tools.android.com/recent/androidstudio0814inbetachannel)) – MathieuMaree Nov 03 '14 at 13:50
  • If you click File -> Project Structure, is the path to your SDK shown there correct? (I doubt this is the issue, but best to check.) – stkent Nov 03 '14 at 13:56
  • Just checked, it's the right path :(. Don't know if you saw my edit, but I only have this issue on one project, the others seem to be just fine... – MathieuMaree Nov 03 '14 at 14:00
  • Yep, saw that. Did you bump the gradle plugin version when you upgraded AS to 0.9? Again, probably not the issue if other projects are fine... – stkent Nov 03 '14 at 14:08
  • Mmmh I'm not sure about that, what do you mean by "bump" ? If you mean upgrade the gradle version, I have no idea... I guess I'm using the 0.14.0 as stated in the build.gradle – MathieuMaree Nov 03 '14 at 14:23

2 Answers2

2

try addind this to buid.gradle

compile 'com.android.support:support-v4:21.0.0

and change build tools version to 20.0.0

Also create a whole new project and see if the same errors are still present in that project.

Try "Tools" -> "Android" -> "Sync Project with Gradle Files"

Hirak Chhatbar
  • 3,159
  • 1
  • 27
  • 36
  • The thing is, I want to use the support-v13, not the support-v4 lib. Plus, it was working 12 hours ago without the v4 – MathieuMaree Nov 03 '14 at 13:47
  • try creating a whole new project and see if the same error occurs on that project – Hirak Chhatbar Nov 03 '14 at 13:48
  • As described in my question, I've already done that... It worked fine for a few minutes and eventually ended up not working any more. – MathieuMaree Nov 03 '14 at 13:52
  • u havnt mentioned about createing new project. (i m not talking about re-importing the same project, but creating another sample project). anyways update ur question with all xml files u have. (manifest file more importantly) bcoz this r errors are mostly due to xml files – Hirak Chhatbar Nov 03 '14 at 14:00
  • No offense, but yes I did : "Something really weird is that I also tried to create a whole new project from scratch and to copy/paste all my classes & resources from my corrupted project to this new one. And it worked for a while (~10 min), until it eventually became corrupted the same way, without any apparent reason." Don't get me wrong, I'm grateful to you for trying to help! – MathieuMaree Nov 03 '14 at 14:11
  • check ur xml files... (upload them) – Hirak Chhatbar Nov 03 '14 at 14:13
0

Well, still not a clue what caused this problem but it would look like I managed to get rid of it, although I had to create a new project from scratch. What I really don't understand is that I've already done this yesterday and it didn't work out.

MathieuMaree
  • 7,453
  • 6
  • 26
  • 31