I have just installed Android Studio and I am a beginner in app programming. I got the following error when I first launched the Android Studio.
Rendering problems
The following classes could not be found
- android support.v7.internal.widget.ActionBarOverlayLayout (Fix_Build_Path, Edit_XML, Create_Class)
Tip: Try to build the project
What might be the cause of this error and how should I fix it?
Changing AppTheme parent in res/values/styles.xml resolved this problem. Replace
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
with
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Downgrade API level from 22 to 21 in Preview Pane
I created a project in Eclipse, worked a lot of in it and changed my IDE to Android-Studio. Now I need to change some things in style.xml and found out, that i did not was generated.
It possible to let it generate now?
PS: I added the library com.android.support:support-v13:22.1.1 to my project.
It could be under themes.xml
Here's a simple styles.xml template with my Activity extending AppCompatActivity
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
</style>
</resources>
It's under res->values->styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorTextPrimary</item>
<item name="android:textColorSecondary">#color/colorTextSecondary</item>
</style>
This is the styles.xml file. The following code results in this error - i have put all the necessary libraries and jar files and i have also tried changing the syntax little bit and many stuff but I am not able to solve the problem. It is very important. Please help me. Thank you.
I have tried the following :
You need to reference this AppCompat library in your Android project.
Import the library into Eclipse.
Right click on your Android project.
Select properties.
Click 'add...' at the bottom to add a library.
Select the support library
Clean and rebuild your project.
It still doesn't work.
Edit now :
I have installed android sdk 5.0 (API 21) but it still doesn't work. The line with the error is
There were 3 other errors before installing android sdk 5.0 (API 21) in this file (styles.xml) but now they are gone. Please help me to remove the remaining error.
If you are using material in the manifest, you will get this error if your min version isn't API 21
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.
Getting errors in style.xml when i change build target to 2.3.3, I think i need to change the theme from holo to something but i don't know any theme names
Here the line where the errors are
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
Holo theme is not supported for old android versions. A quick option could be this
<style name="LightThemeSelector" parent="#android:style/Theme.Light">
...
</style>
More Themes Info
if you are using advanced features like action bar..etc there is one library project called SherlocActionBar you can try with this