43

Got the above error after downloading L preview release version in Android Studio, when my project had minSdkVersion 19.

Furthermore, when setting mindSdkVersion as below:

defaultConfig {
....
          minSdkVersion 'L'
....
    }

I get dozens of errors as below, regarding resources from AppCompat-v7-21 :

/home/user/workspace/project/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0-rc1/res/values-v21/values.xml
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.

So I have 2 questions:

  1. Why does AS complain about minSdkVersion ? I presume because AppCompat-v7 21 supports only L release; but why ? Also, will it support only L release when it is going to be officially released in autumn too ? Because that would be a problem... Or is it just a temporary restriction in order for apps not be be pushed to Play Store, as specified in the Google I/O 2014 Keynote ?
  2. Why does AppCompat-v7 21 complain about those errors, as I already set mindSdkVersion to L ?
Bogdan Zurac
  • 6,348
  • 11
  • 48
  • 96
  • include version number also with the support library... in build.gradle compile 'com.android.support:appcompat-v7:19.+' – Deniz Aug 14 '14 at 09:32

6 Answers6

56
compileSdkVersion 'android-L'

BOOM. Done.

LAST EDIT: As of Android 5.0 release, this is no longer an issue, just target API level 21 directly.

Edit for clarity: Indeed as David_E specified below, this solution only works for L version, if you try to deploy the app on a device below L (ex <=4.4.4) it will complain of OLD_SDK. In order for the app to work pre-L you still need to use the old v20 support lib + app compat + targetVersionSdk and compileVersionSdk

dependencies {

        compile 'com.android.support:appcompat-v7:20.+'
        compile 'com.android.support:support-v4:20.+'
    }

    android {
        compileSdkVersion 20
        buildToolsVersion '20'

        defaultConfig {
            applicationId "com.example.application"
            minSdkVersion 10
            targetSdkVersion 20
            versionCode 1
            versionName "1.0"
        }
}
Bogdan Zurac
  • 6,348
  • 11
  • 48
  • 96
  • 2
    So I can compile with the L SDK and target Android 4.X ? – Dimillian Jun 30 '14 at 09:10
  • 1
    still got Failure [INSTALL_FAILED_OLDER_SDK] :/ on Android 4.2 devices – Dimillian Jun 30 '14 at 10:01
  • Oh crap, I read that wrong, sorry. No, I tried that before upgrading my N5 and it didn't work. But I was more interested in my app working on all version, not being targeted or compiled on L. I guess this is exactly as they described at the keynote (you can't use L apps on Play yet). – Bogdan Zurac Jun 30 '14 at 10:21
  • Okay, so what I did is I reverted to 19, and now I don't get the magnified error anymore and it launch on Both Android L and previous version. Sound like a cache error or something. – Dimillian Jun 30 '14 at 10:22
  • You can use 20 as well. See above, updated my answer to reflect all changes. – Bogdan Zurac Jun 30 '14 at 10:26
  • Same here It wont let me deploy on API 19 and 16 – somerandomusername Jun 30 '14 at 10:34
  • How come that I even uninstall sdk and build tools 21 - Android Studio has only 19 available in support repository and this is still happening? – Michal Jun 30 '14 at 10:46
  • @Andrew I noticed you put another android {} section within your dependencies {} section. Is this a mistake or do I have to put one there as well? Basically I have android { ... } dependencies { ... } right now. But according to your post I need to add another android { ... } section inside dependencies correct? Sorry I'm still a noob with gradle. – Ashok SoThree Jun 30 '14 at 17:45
  • @AshokSoThree no, there isn't any android{} inside dependencies{}. The bracelets are confusing indeed, but check again. – Bogdan Zurac Jun 30 '14 at 19:13
  • 1
    Any news on when Google will be fixing com.android.support:appcompat-v7:21.0.0-rc1? And if not, where should one look for that information when it is available? Thanks in advance! – Forrest Bice Jul 03 '14 at 05:47
  • I can only build using `compileSdkVersion 'android-L'`. But then I can't deploy on any older version. The other fixes don't work. Maybe some of my libraries is referencing v4+. How to fix this? I can't change the libraries. No workarounds are working! – User Aug 04 '14 at 14:28
  • Excellent, simple and perfect solution. Just change compileSdkVersion 21 to 'android-L' i.e compileSdkVersion 'android-L' – sandeepmaaram Jan 14 '15 at 06:45
32

The answer stated here may not work properly, as it will make your app only work for Android L.

In order to conserve the backward compatibility with older Android OS versions, change the gradle dependecy

From:

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

To:

compile 'com.android.support:appcompat-v7:20.+'

Note that the error complains about com.android.support:appcompat-v7:21.0.0-rc1, the reason for that is that using appcompat-v7:+ will tell gradle to import the latest dependency of the appcompat-v7 library, unfortunately this latest version is only working for Android L, so we have to point to a previous version.

Hopefully Google will fix this in the near future.

Community
  • 1
  • 1
David_E
  • 7,130
  • 4
  • 26
  • 29
  • This isssue in Google Code: http://code.google.com/p/android/issues/detail?id=72991 , marked as "released" as for July 28, 2012 – Mixaz Oct 29 '14 at 08:22
4

The way that worked for me was to install the Android Studio Beta (Not Preview Release, the Beta was launched today as part of IO).

Uninstall the preview release and install the Beta and open your project. It will ask you to use project SDK or Studio SDK, use Android Studio's SDK.

Go to your projects local.properties file and where you have sdk.dir ensure that any backslashes () are doubled up .e.g. \.

Go to Project Structure > SDK and ensure this pointing to the Android SDK on my Pc it was C:\Program Files(x86)\Android\android-studio\SDK.

Then in your projects and any libraries you have build.gradle files where you have

compile 'com.android.support:support-v4 Change it to compile 'com.android.support:support-v4:20+

Resync the gradle files and all fixed

Boardy
  • 35,417
  • 104
  • 256
  • 447
4

To force working with a working version Just change the gradle dependencies like this:

dependencies {
    compile 'com.android.support:gridlayout-v7:19.0.1'
    compile 'com.android.support:appcompat-v7:19+'
    ...
}

was:

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

N.B.

I updated Tools & Extras in the SDK manager.

after the project was broken I fixed it as shown above.

For now I do not update android L & 4.4W (enough bugs for today :-( )

BubbaGum
  • 121
  • 1
  • 5
2

Thanks David for your answer!

I had to change

compile 'com.android.support:support-v13:+'

To:

compile 'com.android.support:support-v13:20.+'

And everything work perfect now.

0

Just in addition: The other answers here did not fix the problem for me, but I found an alternate way to fix the android-l problem on Android Studio 0.8.0. After I did change the dependencies in the build.gradle, the problem sadly kept occuring, that the code would say OLD_SKD. I'm using a Galaxy S2.

Apart from changing all things to :19+:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19+'
    compile 'com.android.support:support-v4:19+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:mediarouter-v7:19+'
}

It still would not work, so I had to move back everywhere possible:

android {
    compileSdkVersion 19
    buildToolsVersion '19.1'
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }

Now the app works again on the phone. I should probably get a new mobile, but for now, I hope this may help someone.

Oakenwind
  • 111
  • 8
  • The reason you still had the issue was because one of your dependencies had a sub-dependency that was grabbing the latest version of the support library. – Jason Robinson Jul 14 '14 at 07:07