appcompat_v7 library error in eclipse when create new application - android

I am working with eclipse juno and when i create new application so it contain error.
I am go through with following solution but still the error is there.
1. clean and build the application
2.Add the appcompat_v7 library
please help me to fix this error.![I have added and clean the project but still the error are there][2] [2]:

Do as directed:
Delete appcompat_v7 library library from your project. You will find some errors in your main project.
You will find errors in your styles files in the values folder.
(i) Apply the following lines of code in the styles.xml of your values folder which contains error:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
(ii) Apply these in styles.xml of values-v11 folder:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
(iii) Apply these in styles.xml of values-v14 folder:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Inside menu folder, replace app:showAsAction="never" with android:showAsAction="never"
Finally in your MainActivity replace ActionBarActivity with Activity. Remove all the unnecessary imports.
Now hopefully, your project is ready to run.

That is may be because you are not added the appcompact_v7 support jar file to your project properly.Check this link How to add support libraries? will be helpfull.dont forget to restat your eclipse after adding the jar file.
1)add your support library to your project explorer.
2)add jar file inside it to your android project,as suggested in the above link.
3)clean and build your project(or restart eclipse).

Related

Error with Gyrobot project for android in Github [duplicate]

below is my xml file.It gives me err saying thaty "error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'."
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
Change parent attribute to parent="android:style/Theme.Holo.Light.DarkActionBar"
Right-click your project in the Package Explorer > select Properties > select Android > and set Project Build Target to API level 14 or higher.
Right Click your project->properties->Android, then Add android-support-v7-appcompat
You can import this library from your android-sdk folder->extras->android->support->v7->appcompat

Android development through Eclipse

I try to use the android development tools trough Eclipse Luna.
Exactly I try to use the JBoss for cordova developmet
I have a problem to run the Android emulator. So I tried first to create a clear Android Application project and it have the following error.
What should I do to fix them and run the emulator properly?
styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
ActionBar is found in support library v7. Maybe it's missing.
You can right click in your project -> Properties -> Android
There you should see a library added with a green mark like the following:
If you don't have any library there, you should import the library by going to: File -> Import -> Android -> Existing Android Code Into Workspace
Then look for your library v7 into the sdk folder like the following picture:
Then click finish:
And go back to right click on your project and go to properties to add the library by clicking in the Add... button and selecting the library:
Hope this solves your problem!

Android 5.0 - Intellij Gradle: Cannot resolve symbol: #color:material_blue_500

I am trying to customize the material design theme as suggested in this link :
android dev
but when I add the following code to my v21/styles file Intellij says that it cannot resolve these symbols.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">#color/material_blue_500</item>
<item name="colorPrimaryDark">#color/material_blue_700</item>
<item name="colorAccent">#color/material_green_A200</item>
</style>
</resources>
I looked around to see if there are any particular settings that need to be done on the color side but nothing came up. I am using API 21 with support lib v7 on gradle.
#color/material_blue_500 and others are not the resources in android library.
You must define the color resources in res/values/colors.xml by yourself.
such as <color name="material_blue_500">#5677fc</color>.
And then you can use it as <item name="colorPrimary">#color/material_blue_500</item>.
Android docs are very vague on this, leading to confusion. To get the predefined colors copy color_material.xml to your local res/values dir. That file is a preserved version as it was during Android-L. The offical version which sits in your local directory:
...sdk/platforms/android-21/data/res/values/colors_material.xml
has been trimmed down to remove those color definitions.

R Cannot be resolved to a variable.

I am trying to run an simple android project from a tutorial, However I am receiving the popular "R cannot be resolved to a variable" error. I have checked my gen folder and the R.id file is not there. This is the list of things I have tried so far:
have done a clean build several billion times.
fixed the project properties
There are no errors in my .xml files and they do not contain uppercase letters etc.
The package name in the source and manifest are exactly the same.
Have installed the latest SDK updates + restarted eclipse.
have deleted the gen file and done another clean build.
There is only an error in the source files, according to eclipse.
Here is a themes.xml file that may be causing a problem:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">#+color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>
<!-- ActionBar tabs text styles -->
<style name="MyActionBarTabText"
parent="#android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
</style>
</resources>
Apologies in advance if this sounds familiar, but I have tried everything I have seen from previous posts.
Happy to provide more details if needed. Thanks in advance.
Theme.Holo and Widget.Holo.ActionBar requires API Level 11
TextAppearance.Holo.Widget.ActionBar.Title and Widget.Holo.ActionBar.TabText requires API Level 13
Check your android:minSdkVersion. If it is less than 13 than you can't build your project(or you have to duplicate your styles for different API Levels, using different api level folders under res). eclipse shows this kind of errors.
And also your Android Project Build Target must be at least API Level 13.

Android ActionBarCompat library

I'm having trouble using ActionBarCompat support library which was released yesterday. I have updated support repository and included path to appcompat-v7 repository in build.gradle as Chris Banes pointing out in DevBytes - https://www.youtube.com/watch?v=6TGgYqfJnyc .
dependencies {
compile ('com.android.support:support-v4:18.0.+')
compile ('com.android.support:appcompat-v7:18.0.+')}
Build goes well and I can use classes such as ActionBarActivity from this library but I cannot use styles and any resources so I cannot use following themes - #style/Theme.AppCompat etc. I was thinking that I'll find source files in .../sdk/extras/android/.../"supportrepo" so I would reference it like ActionBarSherlock by gradle but that didn't seems to be the correct answer.
What am I doing wrong? Thank you.
I'm using Android Studio and I have the same res-resolving issue in the my values/styles.xml.
It says it cannot resolve #style/Theme.AppCompat.Light, but at compile-time (gradle) and runtime everything works fine (Android 2.3.3 & 4.3).
I'd like to get rid of the warning that the res cannot be resolved.
How can I tell Android Studio that this res can be found in the appcompat-v7 repo?
(This question was related to a bug in Android Studio that has already been fixed.)
Below you see what I did. I hope this will help. Suggestions appreciated.
The source for the appcompat library can found on github.
Gradle integration:
dependencies {
...
compile group:'com.android.support', name:'appcompat-v7', version:'18.0.+'
...
}
Style-files:
values/styles.xml:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/ActionBar.Solid.Custom</item>
</style>
<style name="ActionBar.Solid.Custom" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_custom</item>
<item name="displayOptions">homeAsUp|showHome|showCustom</item>
</style>
</resources>
values-v14/styles.xml:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 14 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBar.Solid.Custom</item>
</style>
<style name="ActionBar.Solid.Custom" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_custom</item>
<item name="android:displayOptions">homeAsUp|showHome|showCustom</item>
</style>
</resources>
MainActivity (only the extend is mandatory):
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Views.inject(this);
setupNavigationDrawer();
}
}
AndroidManifest.xml (setting android:theme is mandatory):
<activity
android:name="com.example.app.MainActivity"
android:theme="#style/AppTheme"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
There is a known bug (http://code.google.com/p/android/issues/detail?id=56312) where the Android Studio IDE will flag the style as red (that bug is for ActionBarSherlock, but the issue is to do with an aar containing styles and the sources for that aar not being visible to Android Studio).
Specifically, comment #8 (http://code.google.com/p/android/issues/detail?id=56312#c4) shows the observed behaviour, and comment #10 (http://code.google.com/p/android/issues/detail?id=56312#c10) notes that the layout editor is fixed, but the code editor is not.
Thus, the program should build & run fine, just show the style in red when viewed in the XML style editor.
I have not tried Gradle yet so I am not sure but it seems you also need to copy resources into your project.It contains Theme.AppCompat.
I got success in Eclipse by following below steps.
Import android-support-v7-appcompat as a libray project from below path.(you might have saved sdk on different path)
D:\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\extras\android\support\v7
The I just added this library into my project and things worked out of box.
I also added the same 2 lines to my dependencies section in the build.gradle file. Compiling started to work but I got runtime errors. Then I discovered the option Tools > Android > Sync Project with Gradle Files. This seemed to do the trick. (I'm on Android Studio 0.2.9)
In my case, Lastest Studio 0.8.1
Create new project and set Style to AppTheme. then crash.
My solution:
File -> Project Structure -> Dependicies -> + (plus) -> select appcompact, support, ....
And error fixed.
thanks.
Cf https://plus.google.com/113735310430199015092/posts/ef5LyGyMddy
David Van de Ven
Except someone forgot to update the support repository, so anyone
using android studio will have their gradle builds break when trying
to use the new support library.
Roman Nurik
+David Van de Ven we're working on that.

Categories

Resources