1

I had my project working fine in Android Studio but then:

  • I upgraded to Windows 10
  • That broke my java install, but I have that working as well now (removed everything then reinstalled)
  • I now also updaded to latest stable Android Studio

But when I try build my project now, I get 100+ errors in this:

W:\android-studio-projects\mycustomer\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\22.2.0\res\values-v21\values-v21.xml

Where each error/line is like this:

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.

...

Someone asked how my app/build.gradle looks like:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:17'
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "dk.company.app"
        minSdkVersion 9
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }

  repositories {
    maven { url "https://jitpack.io" }
  } 
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.github.PhilJay:MPAndroidChart:v2.0.8'  
    compile 'com.android.support:appcompat-v7:22.2.1'
}

I just inserted the 4rth line in dependencies

compile 'com.android.support:appcompat-v7:22.2.1'

However, it has never been necessary in the past though and inserting it has not fixed my problem. (Why is it suddenly necessary anyhow. Could I maybe remove the dependency - that would fix the issue as well?)

...

Something else that I find peculiar, but probably happens because the project never compiles correct, is that this code:

import dk.company.app.R;

always highlights "R" in red - i.e.cannot resolve symbol 'R'

However, my guess is that it never got as far as generating the file, but stopped when encountering the other appcompat compile errors

...

I can see there are some known similar problems to this:

However, the solutions proposed. I have removed API 22 and API 23 all places in Sdk manager and file system I could fine. I have changed build tools and appcompa version to 21.1.2

Nothing worked sofar

Tom
  • 3,587
  • 9
  • 69
  • 124
  • 1
    check if you have (compile 'com.android.support:appcompat-v7:22.2.1') in your build gradle file. if you dont, you need to add that in and sync the gradle – Tasos Sep 28 '15 at 19:46
  • Tried it, but no luck. However, i have now expanded my question with more information which may provide useful information. – Tom Sep 28 '15 at 22:07
  • possible duplicate of [AppCompat v7 r21 returning error in values.xml?](http://stackoverflow.com/questions/26457096/appcompat-v7-r21-returning-error-in-values-xml) – EJK Sep 29 '15 at 00:46
  • @EJK It is similar, but I already tried the answers there. Maybe my question is a variation of it though. I have expanded my question further with things I have tried – Tom Sep 29 '15 at 01:01

3 Answers3

3

There's a couple things you can do in attempt to solve this:

  1. Clean project option in Build
  2. Rebuild (not build) project option in Build
  3. Invalidate caches / Restart option in File

Try these, it's a glitch with Android Studio where it doesn't compile everything sometimes.

nbokmans
  • 5,492
  • 4
  • 35
  • 59
  • Tried all 3 things now :( - also after Trying @Tasos suggestion, but no luck (upvoted though) – Tom Sep 28 '15 at 22:07
1

The com.android.support:appcompat-v7:22.2.1 dependency requires you to compile your project with at least API Version 22 (5.1 Lolipop).

You're currently targeting and compiling using API Version 17 (4.2 Jelly Bean). You can still leave the targetSdkVersion as 17 (if you want) but you must compile with API Version 22+.

Try changing:

compileSdkVersion 'Google Inc.:Google APIs:17'

to:

compileSdkVersion 22

Note: You may also need to download the API Version 22 platform.

Edit: I see you've updated your question that you've attempted to use the v7:21.x.x appcompat library instead. This would require you compile using at least API Level 21 compileSdkVersion 21.

Khalos
  • 2,335
  • 1
  • 23
  • 38
  • Fixing compiledSdkVersion togther with deleting neverw APIs (23) and build tools in Sdk manager and file explorer seems to have done the trick. I will test it completely now to make sure everything works 100% – Tom Sep 29 '15 at 01:55
1

I have gotten this error quite a few times. I compiled a list in this answer of every way I've ever gotten it working again.

EDIT: Just thought of another one that is more likely to be relevant to what you're describing. If you had been compiling against SDK 17, and when you reinstalled Java you upgraded to Java 8, this may cause incompatibilities. I believe only SDKs greater than 20 can compile against Java 8. Also, moving from SDK 17 to 20+ may break your styles, which will cause your xml files to be invalid, which will prevent R from building. Look in res/values/styles and see if it's failing to find your style. If so, change it to a valid style for your new SDK, clean and build.

Community
  • 1
  • 1
TBridges42
  • 1,849
  • 1
  • 19
  • 29