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:
- 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 ?
- Why does AppCompat-v7 21 complain about those errors, as I already set mindSdkVersion to L ?
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 tocompile 'com.android.support:support-v4:20+
Resync the gradle files and all fixed
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
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+:
It still would not work, so I had to move back everywhere possible:
Now the app works again on the phone. I should probably get a new mobile, but for now, I hope this may help someone.
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:
To:
Note that the error complains about
com.android.support:appcompat-v7:21.0.0-rc1
, the reason for that is that usingappcompat-v7:+
will tell gradle to import the latest dependency of theappcompat-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.
To force working with a working version Just change the gradle dependencies like this:
was:
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 :-( )
Thanks David for your answer!
I had to change
To:
And everything work perfect now.