Rendering Problems - Following Classes Not Found - android

I recently updated Android Studio to version 1.2 and my AppCompat library to v22.0.0, SDK-Build-Tools version to 22.0.1. My target and compile sdk-version is 22 and my 'min-sdk-version' is 16.
The problem I am having is that in the xml-layout preview, I am getting an error namely: "Rendering Problems, the following classes cannot be found: android.support.v7.widget.Toolbar". I did some surfing on the internet and tried the already provided solutions. They are as follows:
Changing my (xml) preview to show android version target 21 or Android 5.0.1, 19, and 17
Changing my styles theme to Holo.NoActionBar and other themes as well.
Changing my minSdkVersion to 21 (above 20 basically)
Restarted Android Studio... Twice
Built the project about 5 times.
However, the problem still remains and I'm out of ideas. Could really use some help here. Thanks...
Also: The classes import just fine in my java file. It's just the preview.
EDIT: The preview works fine when I use android.widget.Toolbar. And my DrawerLayout doesn't work. I'm guessing there's something wrong with rendering the widgets from the support libraries?

I had a similar problem and you may want to try to change the app theme in the style.xml to an appcompat app theme for example with mine I changed it to something like this.
<style name="AppTheme" parent="#style/Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<!-- Customize your theme here. -->
</style>
and then go to the Android Manifests file
<application
android:theme="#style/whatever_you_named_your_app_theme">
In the Android Manifests file you write whatever you wrote in the styles.xml under <style name=""
There is no need to lower your apps targetSDK.
Give me feedback if it worked for you

I wiped out my entire project and started all over again. That seemed to solve the problem. I'm guessing changing my configurations in between is what caused the mess. Thank goodness the project was just for recreation.

Related

Intellij Idea 2018.2.5 CE Android development issue, android sdk v28 is unstable/rendering issue

First of all, I researched alot and this question is not a duplicate of Rendering Issue in Android Studio its answer doesn't fix my problem (i already have the same configuration that is in its answer). Secondly I tried cleaning project, rebuilding project, running gradle sync too. Issue still persist.
After starting a new project, i used to load a template basic activity but the layout xml files are actually not rendering.
Error:
It says Failed to instantiate one or more classes inside that i see
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.
If this is an unexpected error you can also try to build the project, then manually refresh the layout.
Exception Details
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
Copy stack to clipboard
my styles.xml file is:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
My gradle is using this dependency: and compilation and target sdk version is 28
implementation 'com.android.support:appcompat-v7:28.0.0'
Right now it looks like:
EDIT 1:
So now at this point, i tried many things and found myself that the rendering issue is only in SdkVersion 28. When I use
android {
compileSdkVersion 27
defaultConfig {
targetSdkVersion 27
...
}
...
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
...
}
It doesn't appear to be, so I want to investigate what's wrong with sdk version 28? I mean like whenever you make a project you get default config for version 28 and when i try this above snippet i still get warning that v27 is older, why? if v28 not stable enough then why is it default? I don't understand I want some useful answer for why this is!
Thanks everyone who used time to read my question.
Before proceeding with the answer, make sure you have the latest Android Studio. It handles API v28 in a much better way. This update on its own might solve your problem, but if it doesn't, read below:
AndroidX
Try migrating to AndroidX. In the latest Android Studio 3.2 there is a feature called 'Refactor to AndroidX' under the 'Refactor' menu, which makes the whole process easier.
AndroidX is basically google renaming all of the packages to make the naming clearer. More information on that can be found here and here.
I know this is not a direct answer to your question, but I am confident it will solve it. There are many bugs and other irritating errors that Android Studio produces, that I don't see any other IDE makes - I am referring to those that are unclear about what went wrong.
I believe by making AndroidX google addresses this issue in some way. It does definitely make some things clearer and easier, and I recommend migrating to it, in order to solve your problem, and for good practice.

Use Theme.AppCompat in a xamarin.android app

I'm trying to make an Android app through Xamarin. I work on Windows 10 with VS2015.
I have to implement a side bar menu. After some research I found a solution to do it : use a DrawerLayout and others tools. That's why I use Theme.AppCompat in my application.
But when I'm trying to make a style which herits from Theme.Appcompat.light.NoActionBar, I got compile issue. The message is :
Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.AppCompat.Light.NoActionBar'.
I've added Xamarin.Android.Support.v4 and Xamarin.Android.Support.v7.AppCompat references to my project as bellow :
Project References
Edit: I also tried to add them by xamarin Component and nuget package manager.
But nothing compile.
Here is the code which produce this error:
<resources>
<style name="DailyCoin.HomeTheme" parent="#android:style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#219653</item>
<item name="drawerArrowStyle">#style/MyDrawerArrowStyle</item>
</style>
<style name="MyDrawerArrowStyle" parent="#android:style/Widget.AppCompat.DrawerArrowToggle">
<item name="color">#F5F5F5</item>
<item name="spinBars">true</item>
</style>
</resources>
minSdkVersion is 17 and compile using version is 23
Ok, I found the solution.
My problem was that xamarin was corrupted and the component adding module had some troubles when i added components. So i removed all references/components i've added to my projet, reinstalled xamarin.
Just for people impatient like me:
Then i had a new issue : "Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r28.zip" because when generated the solution, it took a lot of time and i stoped this.
The solution was to delete all zips in "%localappdata%/xamarin/zips" and wait for the generation.
Thank for your help !
Julien
Did you try this?
parent="Theme.AppCompat.Light.NoActionBar"
Check this out (its working for me): Navigation Drawer using material design
Leave out #android:style/ so just:
parent="Theme.AppCompat.Light.NoActionBar"

Android Studio Rendering Error: Missing Styles

I'm trying to learn Android through the tutorials at TheNewBoston.com.
In the tutorial, I'm supposed to switch to the material light theme. That's when I get the error. It says:
Missing styles. Is the correct theme chosen for the layout?
Here's a screen shot:
Here's what I've tried:
I've tried switching out of Android API 23, N preview for a lower
API
I've tried changing code in the styles.xml file from
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
I've tried invalidating the cache and restarting.
Nothing seems to be working. I'm very new at Android and just want to get the IDE set up correctly. I also get this message on startup and I think it's related to the error:
Change your layout Preview from API N to API 23. also select target and compile sdk version 23.
Change Compile sdk version and Build SDK version
Have you added this line to your build.gradle file under dependencies
compile 'com.android.support:appcompat-v7:23.2.1'
Note that the support version number might be higher for you. Add below line too to your depedencies
compile 'com.android.support:design:23.2.1'
In theme dropdown at the top of the graphical display of layout. change Theme.
check your theme in style than choose it in the layout too
OR
changed from Holo to Theme and the layout displayed and error disappeared.
check this answer for more detail
Reinstalling Android Studio and right-clicking the shortcut to run the program as administrator sorted out the problem.

ERROR :rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout

I am just a beginner to android app development. When i created a new project on Android Studio 1.1.0,
it gives up this error
"rendering problems
The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout"
Now i have searched about this on google, and i found possibly 3 solutions given by most of the people.
They say:
Either change the api (from preview window pane) from 22 to 21, or
Change the App Theme from "Project Theme" to any other theme.
be sure to have imported right appcompat-v7 library in your project structure -> dependencies,
Refer these steps:
Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:
dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+" }
Note: My android support lib is up-to-date (installed it using SDK Manager).
Following first two steps, removed the error. But I feel that these are not the permanent solutions, the Second step seems just like a temporary workaround. I have doubts about the First step also, that if to remove the error, we change api from 22 to 21, then at the end, our app wont work in Android 5.1.1(API 22), it would be restricted to Android 5.0.1 and below only (API 21). Are my doubts valid?
Regarding the third step, is it the permanent solution to this problem?
P.S : Sorry for mismatching tags, wasn't allowed to add exact tags due to site reputation
Fix res/values/styles.xml like so:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>
Detailed explanation as requested: Theme.AppCompat.Light.DarkActionBar is a subclass of the superclass Base anyway. Ctrl+click (Android Studio) on it and you will be taken to the source:
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />
We didn't change anything, we just defined it more precisely.
This is a known bug since Android Studio build 1.1 (it is also still in 1.2 and 1.3 preview). Switching the preview's API level from 22 to 21 fixes the for most people. While waiting for a fix you could try it as well.
Originally answered here : Rendering problems in Android Studio v 1.1 / 1.2
Just reposting
Modify src/res/values/styles.xml
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>
Then select API22, you'll find this problem fixed!
After this error, I'm using :
API-22 Android 5.1.1 and still this problem exist.But you can at the top of the android studio toolbar, Choose:
Material Light -> Material Light
and then you can see the preview with Toolbar and light theme.
Hope this helps.
I fixed this problem by switching to the Holo Dark theme, then back to the App theme. I just clicked the button above the viewer that says App theme next to the rotate view in Android Studio. About 10% of the time, that alone doesn't work and I also have to change the API of the viewer from 22 to 19.
No idea why this works, but the suggestions provided above did not work for me.
You don't need to change the theme. Maybe your're extending ActionBarActivity (deprecated) instead of just Activity. Change it, and build the project.
If you do change the activity from ActionBarActivity to just Activity, don't forget to import the Activity itself. That is
import android.app.Activity
It sucks but hey, it's their fault and not ours.
Also you can simply change the theme by pressing the "AppTheme" and choose Holo.Light.DarkActionBar. It updates the styles.xml file automatically.After that, rebuild the project.
I did all these and it works for me though i think them guys at Google and IntelliJ should do something about this rendering problem since we have been told to move from Eclipse to Android Studio

android studio change theme to holo crashes app

I have an app I was working on. We wanted to upgrade the minSDK from Froyo to IceCream Sandwich (14) so we could use some of the newer features including the Holo Dark theme.
On StackOverflow we found steps for editing the build.gradle (Module: app) file and changed the minSDK to 14. We resync'd as requested. Then rebuilt the app. All compiled fine and ran on our connected device which is running 4.4.4
I then went to the styles.xml file and changed the AppTheme accordingly.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="android:Theme.Holo">
also as recommended here.
I rebuild the app and it compiles fine. When it attempts to run on our connected device, I get a "The Application has Stopped" immediately.
I looked in the LogCat (per a Comment) and once I figured out what I was looking at, I found this line:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Not sure what that means.
Am I missing something either on the "SDK" change or on the Theme?
Thanks
Pete
Hey can you show your code for said activity? Especially the declaration. I've had this error before and it might have to do witht the fact that you aren't extending (extends) the right actionbar in your activity's declaration.
For example :
extends ActionBarActivity

Categories

Resources