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'
Related
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'm trying to create a new list using RecyclerView to convert my existing ListView but problem is I can't find why my app cannot import the RecyclerView. I've just updated my SDK and other tools so I can work with Marshmallow in the future so everything is updated.
What I have in my app build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23"
defaultConfig {
applicationId "com.test.recyclerview"
minSdkVersion 15
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'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:percent:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
}
and after adding this line on my layout xml I got the error saying The following classes could not be found: -android.support.v7.widget.RecyclerView
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
Downgrading my buildtools and targetSDK version is quite not a good option for me since I only have version 22 and 23 but in case I tried to downgrade my app compat version into 21 it result into this error:
This support library should not use a lower version (21) than the targetSdkVersion (23)
Does it mean that the RecyclerView is removed from app compat 23? or I missed something here?
It appears that something was messed out with my configuration which cause is still unknown. It may be on the IML file or other part but it appears that the libraries are not being imported from the source which is why even after I sync and clean the gradle project the libraries from external source remains the same and still builds successfully.
This may be a stupid question but it's the only thing I can imagine is happening
You said that you had downloaded Marshmallow API but have you downloaded the Android Support Library?
The RecyclerView is part of the support library, not the "normal" SDK
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.
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.
I've imported a library in Android studio (0.5.3)
My settings.graddle looks like this:
include ':app', ':libs:Android-PullToRefresh-master'
And my build.graddle looks like this:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
project(':libs:Android-PullToRefresh-master');
}
The folder I've downloaded is placed in the libs folder directly under the app folder. Also the graddle syncs and building doesn't provide any error. Yet whenever I try to import import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark'. I've chcecked to project structure and the app has the dependency in the list.
What is going wrong and how can I fix this?
I ran into the same issue here and asked the question on the "Android Developer Tools" Google+'s community. Alex Ruiz picked up the conversation and told me:
I'm able to reproduce this issue. Unfortunately, no updates yet. We
are currently fixing the "Project Structure" (the core
infrastructure,) and we will get to this, hopefully soon.
So they are aware of it but we still have to wait until they fix it.
In the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
I had the exact same problem as this, however the library file was an aar file, and it happened a long time after adding the library and developing with it for a while.
Building on the information Thomas provided; I found to fix this you should replace the file dependency with a maven dependency if possible. A good resource for finding and creating your Gradle dependency is Gradle, please.
That site returns the below dependency when searching for PullToRefresh
dependencies {
compile 'com.loopeer.android.thirdparty.pulltorefresh:Android-PullToRefresh:2.1.1'
}