Design preview not showing any device options - android

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.

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

Error inflating class androidx.constraintlayout.widget.ConstraintLayout

After migrating to Androidx packages using Android Studio menu option Refactor -> Refactor to Androidx...
I'm getting the following error:
Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Make sure constraint layout is updated to latest version:
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
And replace your xml tag names
<androidx.constraintlayout.ConstraintLayout>
with
<androidx.constraintlayout.widget.ConstraintLayout>
in every place where it appears using this shortcut:
Windows: CTRL + SHIFT + R
Mac: COMMAND + SHIFT + R
In AndroidStudio 3.3 RC2 I got it resolved by upgrading -
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
in build.gradle (Module: app)
Note:
This solution is also valid for the release version 3.3 (as per below comment by FireZenk), 3.5.2 (as per below comment by user2350644)
Just replace
<androidx.constraintlayout.ConstraintLayout>
with
<androidx.constraintlayout.widget.ConstraintLayout>
In your project's xml files.
You can use Replace in Path shortcut in mac (⇧⌘F or ⇧⌘R) and windows (Ctrl+Shift+R)
Well in my case I've tried Solution 1 which still was not working. Then I used Solution 2 along with Solution 1.
Solution 1
Updating the current version ConstraintLayout in app level build.gradle file.
From
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
Into
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Solution 2
Invalidate Caches and Restart Android Studio (If still not working after applying Solution 1).
File → Invalidate Caches / Restart → Invalidate and Restart
I used both of them and It works fine for me.
Note: Solution 1 is important.
I've also face this issue. This issue occur only for constraintlayout dependecy version.
Use 1.1.3 version & hope your issue will be solved:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
There are two ways to add ConstraintLayout:
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha3'
then you need to use it like this:
<android.support.constraint.ConstraintLayout
...>
</android.support.constraint.ConstraintLayout>
or using androidx:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
then you need to use
<androidx.constraintlayout.widget.ConstraintLayout
...
>
</androidx.constraintlayout.widget.ConstraintLayout>
Do not mix those two.
Since the Android Studio is updated to 3.3 it will pop this error. I resolved it by upgrading the version for constraint layout in the build.gradle of the app level:
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
TO
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
I use an Android Studio 4.1 and this library for constraint layout:
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
which is updated on 09-Nov-20 and had the same error with inflating a Constraint Layout.
In my case on my Samsung a40 app worked but on my ZTE nubia n1 app crashed instantly.
I figured that a problem was in my layout background image because my png image was too big for an old device with a different screen resolution than the Samsung a40.
I imported a background png image through the file explorer (drawable - right-click- Show in Explorer) and there was actually the problem.
I tried to import images with Android Drawable Importer but I notice this plugin does not work anymore on Android Studio.
SOLUTION RELATED TO ANDROID DRAWABLE IMPORTER:
If you have already installed the Android Drawable Importer on your Android Studio please uninstall it before you start the process of repairing.
To repair the Android Drawable Importer you need ADI-hack-plugin which you can get by following this youtube video from Thomas Samoul.
After you repair the Android Drawable Importer just import your image with it and everything will work fine.
I ran into the same problem none of the solutions above worked. The problem, in fact , was caused by a null pointer exception thrown after I switch to NoActionBar theme while the app was using the ActionBar to setTitle(). The linked stack overflow answer helped me figure it out
Android Studio is updated version 3.3. Please remove the previous version constraintLayout
my case used this
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
Thank you
In my case i just had to update the androidx dependencies to the latest version.
EDIT In build.gradle (app) you have to look for the dependencies which contains androidx. Android studio will show you information about the latest versions of these dependencies. Using that information just the change the dependency version.
In AndroidStudio 3.4 I had to downgrade to
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to get it working again.
Strangely, it worked for when I upgraded androidx.appcompat:...' library to
'androidx.appcompat:appcompat:1.1.0-alpha05' with constraint layout version
'androidx.constraintlayout:constraintlayout:1.1.3' on Android Studio 3.3
For those who have tried all of the above to no vain, downgrading constraintLayout worked for me (after I wrecked my head for 3 days trying everything under the sun).
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
to
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'

How to fix "Rendering Problems The following classes could not be instantiated"?

I just started learning android coding and I keep getting this error:
Add these support library in build.gradle and also make sure the version of the support library(goto sdk manager and get the version number of sdk platform and place it in below dependancy because version of support library and sdk platform should be matched)
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
Try any of the following
Click refresh button on the preview pane
Sync Project with Gradle files
Click Tools > Android > Sync Project with Gradle Files
Rebuild Project
Click Build > Rebuild Project
This seems to come up periodically with Android Studio and it happened again today on an install I haven't used in a while. There may be more than one solution, but as of today June 08, 2016, I made sure two things are set:
1) Make sure you're on SDK/API 23 (or lower if necessary) vs the N preview, and
2) change the theme to "App theme". You may have to choose "Manifest Theme" in the left column before you can see "App Theme" show up as an option in the right column.
3) hit the refresh button (looks like two arrows in a circle)
Referring to a post above, both the support.appCompat and support.design libraries should be automatically added as dependencies to the gradle file, but you can double check them if necessary (and get the newest ones if the versions have changed).
You should see both of these:
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
Why Google and Jet Brains can't keep this from happening I don't know, but as of today, it cleared the problem right away.

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.+'

Android Studio rendering problems

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.

Categories

Resources