I'm new to Android programming. I want to use Android Studio (I have the newest one, version 0.8.2), and style my Action Bar.
The Gradle throws the following error during the build process:
Error:Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.AppCompat.Light.DarkActionBar'.
Here's my style.xml file:
<resources>
<!-- Base application theme. -->
<style
name="AppTheme"
parent="#android:style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/SocialExitActionBar</item>
</style>
<style
name="SocialExitActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/tranparent</item>
</style>
</resources>
It's the same as the Google's documentation. In every question, I found, the answer was to add the appcompat Library. But I have the appcompat library added in my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.procode.socialexit"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Here's on pic:
link
Thanks for your help!
I had to remove the #android:style/ before each parent value.
Related
i am using Android Studio and despite all the projects in the old projects folder are working fine, when i try to
create a new project, AS could not recognise AppCompatActivity class
please have a look at the build.gradle and the style folders
please let em know how solve it
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.com.myapplication"
minSdkVersion 19
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
}
style:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
update: after : com.android.support:appcompat-v7:23.1.1
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.android.support:appcompat-v7:23.1.1.
Required by:
MyApplication4:app:unspecified
> Could not resolve com.android.support:appcompat-v7:23.1.1.
> Could not get resource
'https://jcenter.bintray.com/com/android/support/appcompat-
v7/23.1.1/appcompat-v7-23.1.1.pom'.
> Could not GET
'https://jcenter.bintray.com/com/android/support/appcompat-
v7/23.1.1/appcompat-v7-23.1.1.pom'.
> Connection to https://jcenter.bintray.com refused
when i create a new project in android studio i find the the activity class initially extends AppCompatActivity and i have to change it to extend
Activity instead.
but the issue that i am facing is, R class is not recognisable and i receive the error "Cant resolve symbol R". i posted the build.gradle
file below and it seems to me it has no errors.
also, after tryin to find out the solution, i checked all the xml files and i found that the style.xml "posted below" has error at "Theme.AppCompat.Light.DarkActionBar"
and android studio cant resolve it.
please let me know how to fix this error.
code:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.xxx.xxx);//cant resolve symbol R
}
}
style.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">//cant resolve symbol Theme+cant resolve symbol AppCompat
<!-- Customize your theme here. -->
</style>
</resources>
gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.com.bt_11"
minSdkVersion 19
targetSdkVersion 21
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.+'
}
You will have to change the theme to Holo Light or Holo Dark or Material theme as pasted below;
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
I am fighting against Android and compatibility library AppCompat and I am loosing. I come here crying for help.
Since I would like to use a NavigationDrawer (using the code automatically generated by Android Studio) I have to start using the AppCompat library. My app does not work any more because the builder cannot find the theme AppCompat.
I followed all the steps here: https://developer.android.com/tools/support-library/setup.html#add-library
This is the gradle file "Module:app":
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
applicationId "it.misc.application"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':another-library-here.')
}
And this is the res/values/style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
The error is:
Error:Error retrieving parent for item: No resource found
that matches the given name
'android:Theme.AppCompat.Light.DarkActionBar'.
Since I did everything the doc says and I also removed/reinstalled the compatibility library as suggested in an answer to another StackOverflow question, I do not know what else I could try.
Could it be related to the fact that I am using API and build tools ver. 19 and the the Android Support Library 21.0.3? (I think not, but ...)
This is the new gradle, but building keeps failing:
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "it.autostradetech.orchestra.negoziante"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':orchestra.autostradetech.it.')
}
Nothing changes if I set minSdkVersion to 14, 7, 8, or any other random number.
It's not android:Theme.AppCompat just Theme.AppCompat. Only resources from framework have the prefix.
Also change the compile SDK version to 21. The support library version, target SDK and compile SDK versions should correspond.
Replace:
<style name="AppTheme" parent="android:Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
with:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Try changing compileSdkVersion and targetSdkVersion to 21, and change this in your Project Settings also. If you really want to use the appcompat-v7 library, then I suppose minSdkVersion should be at least 14.
EDIT: And it needs to be Theme.AppCompat.Light.DarkActionBar, not android:Theme.AppCompat.Light.DarkActionBar.
Try this solution as suggested in this question.
File->Import (android-sdk\extras\android\support\v7). Choose
"appcompat"
Project-> properties->Android. In the section library "Add" and
choose "appCompat"
I've viewed a ton of posts regarding this issue, but everything here checks out.
Code:
Actionbar:
<style name="CustomActionBarTheme"
parent="#android:style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
Gradle:
compileSdkVersion 'android-L'
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 'android-L'
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21+'
compile 'com.android.support:support-v4:20+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.http-client:google-http-client-jackson2:1.18.0-rc'
compile 'com.google.apis:google-api-services-calendar:v3-rev75-1.17.0-rc'
compile 'com.google.api-client:google-api-client-android:1.17.0-rc'
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile 'com.google.apis:google-api-services-oauth2:v2-rev63-1.17.0-rc'
compile 'com.google.android.gms:play-services:3.1.+'
compile files('libs/app-AppEngine-endpoints-android.jar')
}
Using Android Studio
YES I have support library installed
YES I have tried moving SDK versions all the way up to sdk-18
EDIT
Ctrl-Clicking on the ".../Theme.AppCompat" takes me to the correct lines in values.xml, see below:
<style name="Theme.AppCompat" parent="Theme.Base.AppCompat">
<item name="isLightTheme">false</item>
<!-- Required for use of support_simple_spinner_dropdown_item.xml -->
<item name="spinnerDropDownItemStyle"> #style/Widget.AppCompat.DropDownItem.Spinner</item>
<item name="dropdownListPreferredItemHeight">?attr/listPreferredItemHeightSmall</item>
<item name="searchResultListItemHeight">58dip</item>
Changing this to parent="#style/Theme.AppCompat" causes an error, but by defining that theme in "styles" I managed to fix it at it worked as intended.
I think it's your use of the #android prefix that's causing the problem. I struggled with it for ages until I found this answer:
https://stackoverflow.com/a/19507892/1123654
I try to change my HelloWorld Application holo theme to Material.Light.DarkActionBar theme(As said by What's new Android Development tools session). But I got following error. I try to change target SDK version is 21. But We didn't have 21 SDK in SDK Manager. In that session,they said,set style xml for v-21.
values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
values-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ramapps.helloworld"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Error:
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-20/android.jar -M /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/manifests/debug/AndroidManifest.xml -S /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug -A /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/assets/debug -m -J /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/generated/source/r/debug -F /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.ramapps.helloworld -0 apk
Error Code:
1
Output:
/Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug/values-v21/values.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
You can try to set the values in the build.gradle like this (updated for API 25):
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 21 //oldest version you would like to support
targetSdkVersion 25
versionCode 1
versionName "1.0"
...
}
}
We can not install apps that target L Preview on anything but L devices.
Changing res/values/styles.xml, Theme.Material.Light to Theme.Light and following build.gradle worked for me.
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.example.android.market.licensing'
minSdkVersion 13
targetSdkVersion 20
versionCode 1
versionName '1.0'
}
Although Theme.Material.Light is part of the 20sdk version but somehow it is not working for me.
Set Target of Your Application to API Level 21 from AssemblyMenifest.xml or add <uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" /> tag to your AssemblyMenifest.xml
I changed Theme.Material.Light to Theme.Light and it worked for me.
I think the problem here is that you need to set your buildToolsVersion to pre Android L version.
Here my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 15
targetSdkVersion 19
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:support-v13:19.+'
}
Also make sure to change the styles.xml as below
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Light">
</style>
</resources>
This should resolve the problem.