Android Studio rendering problems - android

I'm using Android Studio 0.2.3 and when opened an activity layout normally, the preview should appear on the right side, so that I can switch between Text and Design mode, which should again show the preview of the layout.
But no preview is shown not on the right side neither when I'm in text mode nor in the design mode. I just get the error rendering problems...
When I compile everything and install the app on my device, it works without any errors. For developing and experimenting with the layout, it would still be nice if I could get the preview to work.
I have also tried to switch between different devices in the studio, but no success.
Does anyone know how solve this?

Change your android version on your designer preview into your current version depend on your Manifest. rendering problem caused your designer preview used higher API level than your current android API level.
Adjust with your current API Level. If the API level isn't in the list, you'll need to install it via the SDK Manager.

In new update android studio 2.2 facing rendering issue then follow this steps.
I fixed it - in styles.xml file I changed
"Theme.AppCompat.Light.DarkActionBar"
to
"Base.Theme.AppCompat.Light.DarkActionBar"
It's some kind of hack I came across a long time ago to solve similar rendering problems in previous Android Studio versions.

Open AndroidManifest.xml
Change:android:theme="#style/AppTheme"to something like:android:theme="#style/Theme.AppCompat.Light"
Hit "refresh" button in the "Previev" tab.

I was able to fix this in Android Studio 0.2.0 by changing API from API 18: Android 4.3 to API 17: Android 4.2.2
This is under the Android icon menu in the top right of the design window.
This was a solution from http://www.hankcs.com/program/mobiledev/idea-this-version-of-the-rendering-library-is-more-recent-than-your-version-of-intellij-idea-please-update-intellij-idea.html.This required a Google translation into English since it was in another language.
Hope it helps.

In the Latest Android Studio 3.1.3, Dependency:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
or
Even in latest by 27th of Aug 18 ie
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
facing similar issue
Change it to
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1
This will solve your problem of Preview.
UPDATE
Still, in beta01 there is a preview problem for latest appcompact v7 library
make the above change as changing it to alpha01 for solving rendering problem

When I set that android:autofillHints="" /> in .xml file, I met the issue, Android Studio rendering problems, so I set that android:autofillHints="testHint" />, this issue is gone.

I have solved the Problem by changing style.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
this was an awesom solution.

it still happens in Android Studio 1.5.1. on Ubuntu and you can solve it simply changing a setting from Gradle:
1) on app/build.gradle dependencies change from:
compile 'com.android.support:design:23.2.0'
to:
compile 'com.android.support:design:23.1.0'
2) rebuild project
3) refresh view
Best regards,
/Angel

I had the same problem, current update, but rendering failed because I need to update.
Try changing the update version you are on. The default is Stable, but there are 3 more options, Canary being the newest and potentially least stable. I chose to check for updates from the Dev Channel, which is a little more stable than Canary build. It fixed the problem and seems to work fine.
To change the version, Check for Updates, then click the Updates link on the popup that says you already have the latest version.

In build.gradle below dependencies add:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.+"
}
}
}
}
This worked for me, I found it on stack, addressed as the "Theme Error solution":
Theme Error - how to fix?

Rendering didn't work for me too. I had <null> value on the right side of the android icon. I ran
sudo apt-get install gradle
I restarted Android studio then and <null> value changed to 23.
Voila, it renders now! :)

Just download minimum prefered SDK from SDK Manager, then build. Works for me.

Make sure your designer version and targetSdkVersion both is same.
Example : If your targetSdkVersion is 22 then change your designer version also 22, so this problem do not occur.

Best Solution is go to
File -> Sync Project With Gradle Files
I hope this helped

All you had to do is go to styles.xml file and replace your parent theme from
Theme.AppCompat.Light.DarkActionBar
to
Base.Theme.AppCompat.Light.DarkActionBar

Open your activity_main.xml .
Switch to Design view if you are in text view.
Look for the android version,with the android robo icon.
Change the android version.
Problem solved.

this issue is probably derived from the connection of the laptop to software products like AnyConnect. Killing the remote connection works for me.

Related

Android Studio xml preview issue failed to initialize editor

After Update android studio dolphin my old projects xml preview not showing views. Is anyone facing same issue? And have done solution then please share it here.
It's run perfectly fine but preview not working.
What I did tried?
File -> Invalidate Cashes / Restart
Delete build , idea , gradle folder
Restart PC and android studio
but none of that solved my problem.
In my case, I have upgraded the project AGP (Android Gradle Plugin) and then restart the android studio.
Problem Solved.
I'm suffering from same issue/bug. What I did so far?
Attempt 1
File -> Sync Project with gradle files
File -> Invalid catch and Restart.
Delete build folder idea and .gradle folder.
Restart Android studio and restarted my pc as well.
This will do solve in one of the my project which is only 5 screen project. But not solved in my other old projects which are more than 5 year old.
Attempt 2
Tried all step from attempt 1 Also tried what siregar2103 answered
File -> Repair IDE but still have same problem ,But Repair IDE did solve my other project issue/bug.
Attempt 3
All from Attempt 1 and 2 but not solve in my main project so I decided to upgrade my years old project to latest one.
I did upgrade my Gradle from 4.1.3 to 7.3.0
Update all dependency to latest one but I face many error while doing that.
Hilt error and other errors too. Which I'm going to mention below.
For Hilt I did removed all old Hilt related library and and below
kapt "com.google.dagger:dagger-compiler:2.42"
kapt "com.google.dagger:hilt-android-compiler:2.43.2"
implementation "com.google.dagger:dagger:2.42"
implementation "com.google.dagger:hilt-android:2.43.2"
implementation 'androidx.hilt:hilt-work:1.0.0'
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation "androidx.navigation:navigation-compose:2.5.1"
In build.gradle file (not .app level)
id 'com.google.dagger.hilt.android' version '2.43.2' apply false
Important note: I did add implementation "androidx.navigation:navigation-compose:2.5.1" dependency because I got
java.lang.IllegalArgumentException: CreationExtras must have a value
by SAVED_STATE_REGISTRY_OWNER_KEY error in runtime.
Other Error which I faced is
Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException:
lateinit property _buildFeatureValues has not been initialized
For this I did build gradle using command line and it give me full error which I didn't get when I directly build don't know why? But It's through error related flat dir and aar file so I did removed flat dir code and change aar file implementation code now It's started to build and my app started to install.
Now still some of my file not rendering and that because of I'm using custom attr from style so I'm trying to figuring out why it's happening and I'll update this answer when I find solution for that.
So using above my 60% xml files preview start showing in my old projects. For 40% screen I have to change my default theme to custom theme in preview of xml so it can start rendering.
Repair IDE
Upgrade your code to latest Android Gradle Plugin
This 2 step should solve your problem. And build using command line for more error related details.
Have you try to using Repair IDE? It works for me
I ran into a similar issue when upgrading to Dolphin. I was able to solve this by changing the preview's theme from App.Starting [default] to my app's theme.
Try to update the gradle and sync files. It work for me.
The XML file in your project may contain an error. The reason may be a font issue or a file not linking correctly with your XML layout.
This is for your reference on how to find errors.
Hope you find it useful.
Check what Layout Inspectors you have enabled in Android Studio and try to let only the API 29-30 inspector active.
In my case if in xml custom views have used that my preview screen not show views if I remove or comment custom views in xml layout after that the preview screen show other view perfectly
I know removing custom layouts not solution.
for solve this issue I do following steps
First I just update Gradle plugin version to 7.3.0 from setting project structure (No working)
after that I also update com.google.gms:google-services version to 4.3.14
now every things work fine.
In my case, I have upgraded Android Gradle Plugin when update is popUp and then restart the android studio.
My Problem Solved.
I am looking as well for a soluition till now.
From what i see, it has something to do with
AGP or Cardview (Layouts). Many code snipeets relate to this issue.
I am trying to update the AGP version, but it seems, that the enveronmet is more broken than that.
I get as well an empty Field for the gradle version and plugin under settings.
For anyone can not fix this issue, i'm just need to update gradle version and buildtool
buildSrc/src/main/kotlin/Dependencies.kt
object BuildPlugins {
object Versions {
const val buildToolVersion = "7.3.0" //lower version seem not work
and change to 7.4 in gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

Android Studio 3.1 can not resolve "Theme.AppCompat" styles properly

Last night, I upgrade my android studio from 3.0.1 to 3.1, and rebuild my project, and I got the error as show below.
CHECKED LIST:
compileSdkVersion 27
buildToolsVersion '27.0.3'
classpath 'com.android.tools.build:gradle:3.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
As mentioned in this question:
Close project.
Remove it from the projects list (left side in the default Android Studio window).
Open existing project -> choose the project folder.
Basically, close & re-open the project.. worked for me (after even invalidating cache didn't work).
Related issues from issuetracker: 77211616, 77938563, 73536373
Even though my first answer works, it's actually a hassle because the issue keeps on reoccurring, especially after I switch branches (for different development or code reviews). So, I read further and found this answer:
Switch your support lib version - either to a newer ver (27.1.1 stable as of now), or to an older version & back to current.
It's an alternative and seems to work.
Related issues from issuetracker: 77211616, 77938563, 73536373

Design preview not showing any device options

I am using Android Studio 3.0 Beta 2 version and I cannot get the design preview to show. There are no devices available in the dropdown. I have tried adding a new device definition.
This is what it looks like:
This is what I want:
What am I doing wrong?
i think you need to update your sdk with another APIs
Add this line of code in your build.gradle
compile 'com.android.support:design:25.3.1'
Turns out the issue was in the gradle file. Once I updated the build tools version the problem went away.

AppCompatActivity is not assignable to Activity

After a year of coding in android and everything working perfectly till yesterday. Today, I found something really strange after upgrading to gradle 3 alpha 2 and studio 3 build 2.
This is the declaration of one of the activities throwing error:
This is the activity code:
What is wrong?
EDIT
appcompat dependency:
compile 'com.android.support:appcompat-v7:23.2.1'
Maybe this will help:
In the app build.gradle, change compileSdkVersion and targetSdkVersion to 25.
Also upgrade the version of the appcompat library to 25.3.1:
compile 'com.android.support:appcompat-v7:25.3.1'
UPDATE 05/31/2017:
As #cricket_007 pointed out to me in comments, it isn't caused by a problem with the non-existence of AppCompatActivity, as I had theorized (in comments).
And while I have not been able to track it down, it looks like the lint checking is behaving differently or misbehaving on Android Studio 3 Preview, or in the 3.0.0 alpha2 version of Android Gradle Plugin, some build tools versions (or somewhere).
If your code is compiling ok (in spite of the "assignable" complaint appearing in AndroidManifest.xml) and you want to keep using Android Studio 3 Preview, maybe it's worth trying to suppress "AndroidDomInspection" on that activity tag for now:
<!--suppress AndroidDomInspection -->
<activity android:name=".admin.AdminChangeCoach">
. . .
</activity>
But, FWIW, I also agree with #cricket_007's earlier comment: I'm not using Android Studio 3 for production yet either.
As an alternative ways, you can simply change the class that you extended to Activity class instead of AppCompatActivity.

How to get new android cast icons

I am trying to use Chromecast icon in my app. My problem is am still seeing the older version of cast image (without white filling on connected). How can I update it newer version with filling?
I followed the post here, and updated the settings in gradle build as but its not working
dependencies {
compile "com.android.support:mediarouter-v7:19.0.1"
}
Perhaps the answer confused you. You should use:
compile 'com.android.support:mediarouter-v7:20.+'

Categories

Resources