I'm trying to use the new CardView from Android L. I updated everything in the SDK manager, but I keep getting the following error:
Failure [INSTALL_FAILED_OLDER_SDK]
This is my build.gradle file:
apply plugin: 'android'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "www.thomascbeerten.com.nieuwetests"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// Support Libraries
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile 'com.android.support:mediarouter-v7:19.1.0'
// compile 'com.android.support:support-v13:19.1.0'
compile 'com.android.support:recyclerview-v7:+'
}
Recently there was a post here regarding the L SDK's incompatibility
with prior versions of Android. I've been digging in AOSP repositories
for quite a few hours now, and determined that the tools behave this
way because they are designed to treat preview platforms differently.
If you compile against a preview SDK (android-L), the build tools will
lock minSdkVersion and targetSdkVersion to that same API level. This
results in the produced application being unable to be installed on
devices running older releases of Android, even if your application
isn't doing anything specific to L. To make matters worse, the new
support libs (CardView, RecyclerView, Palette, etc.) are also locked
into the L API level, even though--according to their repository
names--they should work on API level 7 just fine (and they do!).
See my Reddit post about this here, with a workaround.
Once you have the above issues resolved as mentioned by Eddie. You might also run into another error;;
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
This will be present in your styles.xml . The quick fix is to replace it with the following below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--<style name="AppTheme" parent="android:Theme.Material.Light">-->
<style name="AppTheme" parent="android:Theme.Holo.Light">
</style>
Change
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
to
android {
compileSdkVersion 21
buildToolsVersion '21.0.2'
Note android-L is in single quotes but 21 isn't. 21 is an integer and not a string.
When you compile with L it actually makes a change during compilation setting your minsdkversion to L. If you want to use RecyclerView or CardView I would recommend checking out RecyclerViewLib. RecyclerView and CardView have been moving into this library so that there is no min version L problem. The author also explained in his blog post how all L related code was removed to make it safe to use.
To add RecyclerViewLb to your project just add the following line to your dependencies in your build.gradle file:
compile 'com.twotoasters.RecyclerViewLib:library:1.0.+#aar'
You then do not want to add the compile 'com.android.support:recyclerview-v7:+' to your build.gradle as you will get that through RecyclerViewLib.
I just ran into this problem. This can happen when your min sdk version and built targets are set to a higher API level/OS version than your phone is running. If you're using Android Studio, go to File > Project Structure > and edit relavent settings then Run again.
Related
I'm currently developing an app in Android Studio and have been for several weeks now. I am wanting SDK 21, not 23! SDK 21 has been working for the past few weeks with no problems at all
This morning, I have retuned to my PC to carry on with my programming, went to run the application and these errors appeared:
Error:(3) Error retrieving parent for item: No resource found that
matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(18) Error retrieving parent for item: No resource found that matches the
given name 'android:Widget.Material.Button.Colored'.
Between the app working last night and trying to run the app this morning - nothing has changed. I haven't even closed down android studio. I left my PC on sleep.
I have searched stack overflow and noticed that these errors have occurred for others too. I have tried the answers that have been given to others such as checking the project structure, dependencies, gradle file etc. I have also tried the standard clean and build
This is my Gradle file:
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.example.package"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:21.0.3'
}
Apologies for the images being links, I'm new to SO so can't embed them to a post yet.
It's completely possible that I am missing something obvious but I have been trying to solve this problem for the past few hours and I'm not getting anywhere.
Any help would be greatly appreciated!
Stand Alone SDK Manager Screen Shot
Dependencies
When you added
compile 'com.google.android.gms:play-services:8.4.0'
This dependency requires the 23.0.0 version of the support-v4 library (FWIW, 8.3 and 8.1 require 22.2.0, hence you are compiling with the API 23 versions of the Support Library.
Keep in mind though, the best practice, as described in the Picking your compileSdkVersion, targetSdkVersion, and minSdkVersion is to always compile with the latest SDK:
It should be emphasized that changing your compileSdkVersion does not change runtime behavior. While new compiler warnings/errors may be present when changing your compileSdkVersion, your compileSdkVersion is not included in your APK: it is purely used at compile time. (You should really fix those warnings though — they were added for a reason!)
Therefore it is strongly recommended that you always compile with the latest SDK. You’ll get all the benefits of new compilation checks on existing code, avoid newly deprecated APIs, and be ready to use new APIs.
Therefore the easiest solution is to change your compileSdkVersion to API 23, while leaving your targetSdkVersion (what controls runtime behavior and use of things like runtime permissions) at whatever level you currently have.
try changing
compile 'com.android.support:support-v4:21.0.3'
to
compile 'com.android.support:support-v4:21.1.0'
I decided to reduce my api level from 23 to 22. To begin with, I downloaded android studio with the latest 23 API installed. I installed the 22 API now but I don't know if I installed the other stuff like:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
Can't find where to look if these are installed... So this is how my manifest looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 //changed this, used to be 23
buildToolsVersion "22.0.0" //changed this also, but I don't know if it's installed....
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 22
versionCode 11
versionName "2.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'libs'] } }
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.twitter.sdk.android:tweet-composer:1.0.2#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'//changed this also, but I don't know if it's installed....
compile 'com.android.support:design:22.2.0'//changed this also, but I don't know if it's installed....
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services-identity:8.4.0'
}
So when I try to sync it gives me this crap:
C:\Users\jonathan\AndroidStudioProjects\TrashOmeter\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\jonathan\AppData\Local\Android\sdk\build-tools\22.0.0\aapt.exe'' finished with non-zero exit value 1
How do I get it to compile with 22 sdk correctly???
You wont be able to downgrade from SDK 23 to 22 if have already uploaded your apk (sdk 23) on google play. Store will not let you.
I have already done this mistake and now my APP is disadvantaged compared to my competitors who didnt made this mistake.
So DONT USE SDK 23, it will make your users angry if they have to enable LOCATION for your app (access to wifi channel list is main purpose of my app)
I decided to reduce my api level from 23 to 22
Given the comments in your build.gradle file, you appear to mean that you reduced your compileSdkVersion to 22.
I have no idea why you would do that.
Raising the compileSdkVersion to a newer level is perfectly reasonable and will be required to use some newer versions of dependencies (let alone any new references from your own code). I know of no problems in modern Android development that are solved by reducing compileSdkVersion. You seem to be causing yourself pain for no actual benefit.
I installed the 22 API now but I don't know if I installed the other stuff like
If you have an up-to-date "Android Repository" in the SDK Manager, then you have older versions of the Android Support libraries.
//changed this also, but I don't know if it's installed...
If you have an up-to-date "Build Tools" in the SDK Manager, then you have older versions of the Android Support libraries.
So when I try to sync it gives me this crap:
That "crap" is because you decided to change your compileSdkVersion to 22, yet not change your dependencies to similarly older versions. Your current dependency versions are written with references to things from API Level 23 (in this case, resources) and need compileSdkVersion 23.
How do I get it to compile with 22 sdk correctly?
Reduce the versions of your dependencies to ones that pre-date the existence of API Level 23. For those that you are getting from Maven Central or JCenter (e.g., facebook-android-sdk), you can probably find out dates of artifacts from their Web interface, and try to find ones from August 2015 or earlier. For the rest... you're on your own.
Or, change your compileSdkVersion back to 23.
So thanks to CommonsWare I found the answer. I had to change the google play dependency to a lower version. So in gradle I changed:
From:
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
To:
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.google.android.gms:play-services-identity:7.3.0'
I'll start from what I want to achieve: building the googlecast-manager example provided here: https://github.com/googlecast/GameManagerSamples
I followed instructions here: https://developers.google.com/cast/docs/android_sender
So first I downloaded from github the project, then with the Android SDK Manager I downloaded Android Support Libraries and Google play Services. Then in my project, I went to "Open Modules Setting->Add" then went to "Android SDK\extras\android\support\v7\appcompat" and added it.
Then first step to ensure it's working is to build it. So I right clicked on appcompat->"Compile Module Appcompat" but it fails with 2 errors:
Error:(20, -1) android-apt-compiler: [appcompat] D:\Android
SDK\extras\android\support\v7\appcompat\res\values-v23\styles_base.xml:20:
error: Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Material.Button.Colored'.
Error:(19, -1) android-apt-compiler: [appcompat] D:\Android
SDK\extras\android\support\v7\appcompat\res\values-v23\styles_base_text.xml:19:
error: Error retrieving parent for item: No resource found that
matches the given name
'android:TextAppearance.Material.Widget.Button.Inverse'.
Doing the same for Google Play works like a charm.
I've tried to find videos/other similar issues but it's either too complicated or not my problem.
Here is the AndroidManifest.xml of appcompat:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.support.v7.appcompat">
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19"/>
<application />
Here is what is installed from the Android SDK Manager:
I also encountered the same problem and now have fixed it. What you just have to do is
Inside your Android Studio
press Shift button two times, a search box will appear type build.gradle
choose build.gradle module:app from the suggestion.
major version of compileSdkVersion and support libraries under dependencies should be same as following code depict.
Inside Eclipse
find build.gradle module:app and do the same.
Note: download and install properly the latest API which is now API 23.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.inzi.app"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
I believe you should upgrade your compileSdkVersion. Check your build.grade file, should be something like:
android {
compileSdkVersion 23 // <- here
buildToolsVersion "23.0.0" // <- here
defaultConfig {
applicationId "your.id"
minSdkVersion 11
targetSdkVersion 23 // <- and maybe here
versionCode 1
versionName "1.0"
}
buildTypes {
....
}
}
Of course you will need to download the newest Android SDK and build tools (and whatever else you need) from the SDK Manager.
If you are working in Eclipse do the following:
In your AndroidManifest.xml file change android:targetSdkVersion to 23
Open Project settings (ALT + Enter while focused in Project Explorer)
Go to Android tab and in Project Build Target section mark Android 6.0
Clean and build your project
NOTE: when you do this have in mind that Android OS would treat your app as if it was designed to work on Android M. So for example if you use some dangerous permissions you should add routines to check then on runtime.
You have to update your SDK to the API 23 that is either not downloaded or not installed properly.
In your build.gradle set
compileSdkVersion 23
buildToolsVersion "23.0.0"
targetSdkVersion 23
compile 'com.android.support:appcompat-v7:23.0.0'
I actually found the answer for my problem and the person above was right. The Module SDK set to compile the module was 22.0 and not 23.0. To fix that I did the following.
Right click on appcompat: "Open Module Setting -> Modules SDK": New. I Chose the folder containing the whole Android SDK and chose the last Android (e.g. 6.0) with the last Module SDK 23.0.
Either revert to appcompact-v22 or update to android api v23
You have to update your SDK to the API 23 that is either not downloaded or not installed properly.
Make sure your compileSdkVersion and dependencies version should be same.
I was having problem with new appcompat V-23 as my target sdk is 21. So I did following two steps and it works perfectly for me..
1) Delete the values-23 folder in res folder.
2) I was getting error on the src folder as well, so commented the only line inside main() of snippet.java as we do not require it.
Then add this project as library to your project.. Hope it helps.
I resolved like below
android {
compileSdkVersion "Google Inc.:Google APIs:21"
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
replaced the above dependencies with below...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:7.8.0'
}
To correct this error in android studio procceded like this :
i went to sdk manager and i downloaded and updated all packages of android api 23
file => project structure and i changed compile sdk version from 21 to 23 and build tools version from 21 to 23
The problem generally occurs due to version issues. The following dependencies and compilesdkversion Worked for me:-
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:support-v13:23.0.+'
compile 'com.firebase:firebase-client-android:2.2.4+'
}
The answer #31 & #11 in this discussion can solve this issue:
https://code.google.com/p/android/issues/detail?id=183122
My issue was, one of my un-used dependencies was using sdk-23 version. So after removing those un-used dependencies it worked like a charm.
I am using Android Studio 1.2.2 to develop an Android Application. In my build.gradle file, I have defined the compileSdkVersion to 21 since the beginning of the work. Now I wanted to change that to 19, since this software actually will never be installed on an Android device, that runs a higher version than Android 4.4
When I try to change this value to 19, the project does not compile anymore.
After the change of the version value I have:
synced the project
cleaned the project
rebuild the project (tried)
But the following error occurs:
In the file /projectpath/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values-v21/values-v21.xml it marks 103 errors, saying "cannot resolve symbol".
values-v21.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/lmp-mr1-supportlib-release/frameworks/support/v7/appcompat/res/values-v21/styles_base_text.xml -->
<eat-comment/>
<style name="Base.TextAppearance.AppCompat" parent="android:TextAppearance.Material"/>
<style name="Base.TextAppearance.AppCompat.Body1" parent="android:TextAppearance.Material.Body1"/>
<style name="Base.TextAppearance.AppCompat.Body2" parent="android:TextAppearance.Material.Body2"/>
<style name="Base.TextAppearance.AppCompat.Button" parent="android:TextAppearance.Material.Button"/>
....
cannot resovle symbol android:TextAppearance.Material
cannot resovle symbol android:TextAppearance.Material.Body1
cannot resovle symbol android:TextAppearance.Material.Body2
cannot resovle symbol android:TextAppearance.Material.Button
and so on...
What is causing this error? What can I do to make it compile again?
When I change back the compileSdkVersion to 21, everything works normal again.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '23.0.0 rc3'
defaultConfig {
applicationId 'com.appname.id'
minSdkVersion 17
targetSdkVersion 19
versionCode 1
versionName "0.0.2 Alpha"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
to use appcompat-v7:22.2.0 you have to compile against API 21. There's no harm in doing it, even if it will never run on devices running 21.
You can try some older version of the app compat, but then you will be missing in "cool new features" and bug fixes from the latest app compat.
If this might help someone, after MANY trials and errors, I found that I was targeting the wrong SDK version (an older one) in the build.gradle file corresponding to "library". To change this you can do it by hand or go to the Module Settings Menu (right click on your project folder -> Open Module Settings. Then in "library" - Properties you can change the Compile Sdk and the Build Tools Versions
make sure you have installed API 19 in sdk manager
Situation:
I'm currently building a new version of my app for Android L and am also in the process of Chromecast integration.
The app works fine, as long as I extend Theme.Material with my custom style, but doesn't show the Cast button.
Problem:
As soon as I change to Theme.AppCompat, it gives me the error:
Error:Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.AppCompat.Light.DarkActionBar'.
and the same goes for the the Holo Theme as well.
Here's my build.gradle (The libs folder is empty btw.):
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.myapp.myapp"
minSdkVersion 'android-L'
targetSdkVersion 'android-L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:mediarouter-v7:+'
compile 'com.google.android.gms:play-services:+'
}
Here is the relevant part of the values/styles.xml:
<style name="SK" parent="android:Theme.AppCompat.Light.DarkActionBar">
used to work with Theme.Holo.Light.DarkActionBar
and the values-v21/styles.xml:
<style name="SK" parent="#android:style/Theme.AppCompat.Light.DarkActionBar">
used to wirk with Theme.Material.Light.DarkActionBar
I already cleaned and rebuild the project, but it always goes back to showing me errors about a missing parent.
As far as I could gather from similar questions, all relevant libraries are included and all use the newest version available.
I also tried manually adding the libraries to the libs/ folder with no success.
My SDK manager shows that everything is installed and up to date.
What am I missing here?
Thanks in advance for your time.
Solution:
It was actually rather simple. I referred to Theme.AppCompat with the android namespace, but should have left it out, so, instead of
#android:style/Theme.AppCompat
it should be
#style/Theme.AppCompat
This did show another error initially, about "Theme" not being found, but it compiled non the less.