I have a problem after updating Android Studio version from 2.2.* to 3.0.1. The problem is XML Layout doesn't show in design mode.
API / Device changing didn't solve my problem.
The error message is:
Exception raised during rendering: android/text/TextUtils
Details:
java.lang.ClassFormatError: android/text/TextUtils at
android.content.res.Configuration.setLayoutDirection(Configuration.java:1779)
at
android.content.res.Configuration.setLocales(Configuration.java:1725)
at
android.content.res.ResourcesImpl.calcConfigChanges(ResourcesImpl.java:484)
at
android.content.res.ResourcesImpl.updateConfiguration(ResourcesImpl.java:365)
at android.content.res.ResourcesImpl.(ResourcesImpl.java:161)
at
android.content.res.Resources_Delegate.initSystem(Resources_Delegate.java:90)
at
com.android.layoutlib.bridge.android.BridgeContext.initResources(BridgeContext.java:255)
at
com.android.layoutlib.bridge.impl.RenderAction.setUp(RenderAction.java:242)
at
com.android.layoutlib.bridge.impl.RenderAction.init(RenderAction.java:134)
at
com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:165)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:382)
at
com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at
com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:547)
at
com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:681)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Even if I create clean xml layout, I still get the same error message.
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
Does anyone face this problem before and what is the solution for this?
Update. I did downgrade to 2.2.2 and everything work now. Thanks for suggesting.
Try below trick:
In Android Studio:
Files -> Invalidate Caches / Restart
Please let me know if this solved your issue.
Once i had this issue, and my issue was resolved when i tried changing theme in xml layout.
Also check your theme in android manifest and styles. It can be an theme error.
I am attaching an image for your convenience.
Related
After updating to ConstraintLayout 2.0 I realized that even the simplest layouts can not be previewed properly in Android Studio, both on OS X and Ubuntu.
First, my setup looks like this: I'm using "androidx.constraintlayout:constraintlayout:2.0.0", the version of Android Studio is 4.0.1 (the latest stable release) on both of my computers, the version of Android Gradle plugin is 4.0.1, the version of Gradle is 6.1.1.
Here's an example:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
I would expect it to draw the TextView aligned to the top of the screen.
What I end up seeing instead is this:
I tried turning off the experimental rendering engine as AS warned me there might be some issues with it but to no avail.
Is there something obvious I might be missing? Since 2.0.0 was in release for 2-3 days (and the release candidate was available for a wide audience for longer than that), I assume all obvious glitches should've been resolved at this point.
Upd. AS states there is a following rendering problem:
java.lang.NoClassDefFoundError: Could not initialize class androidx.constraintlayout.widget.ConstraintLayout$LayoutParams$Table
at androidx.constraintlayout.widget.ConstraintLayout$LayoutParams.<init>(ConstraintLayout.java:2603)
at androidx.constraintlayout.widget.ConstraintLayout.generateLayoutParams(ConstraintLayout.java:1823)
at androidx.constraintlayout.widget.ConstraintLayout.generateLayoutParams(ConstraintLayout.java:481)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1125)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1097)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:501)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:348)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:404)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:678)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$8(RenderTask.java:809)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Upd. 2 I've submitted a bug report, let's see if this is a bug with Android Studio / Constraint Layout indeed (which I think is not the case).
Ok, in my case this definitely looks like an issue with a project cache. Once I've cleaned it up (Build -> Clean Project), the layout preview started working just fine.
I am having the same issue after updating to 2.0.0, I believe this is an AS/Constraint Layout issue. Using version 1.1.3, for the time being, works just fine.
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
After updating from Android studio 2.2 preview 4 to 5, Design and Preview tabs stopped to show previews.
They don't show anything, only the error (described below) and a tip "Try to refresh the layout".
Refreshing and choosing different options in a top bar (API, device orientation) doesn't help.
Was trying File -> Invalidate Caches/Restart. Doesn't help either.
Any suggestions?
java.nio.file.InvalidPathException: Illegal char <:> at index 8: #android:drawable/ic_menu_send
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.nio.file.Paths.get(Paths.java:84)
at com.android.ide.common.res2.ResourceItem.parseFileName(ResourceItem.java:585)
at com.android.ide.common.res2.ResourceItem.parseXmlToResourceValue(ResourceItem.java:405)
at com.android.ide.common.res2.ResourceItem.getResourceValue(ResourceItem.java:240)
at com.android.ide.common.res2.AbstractResourceRepository.getConfiguredResources(AbstractResourceRepository.java:393)
at com.android.ide.common.res2.AbstractResourceRepository.getConfiguredResources(AbstractResourceRepository.java:349)
at com.android.tools.idea.configurations.ResourceResolverCache$1.compute(ResourceResolverCache.java:166)
at com.android.tools.idea.configurations.ResourceResolverCache$1.compute(ResourceResolverCache.java:163)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.configurations.ResourceResolverCache.getResourceResolver(ResourceResolverCache.java:163)
at com.android.tools.idea.configurations.Configuration.getResourceResolver(Configuration.java:1212)
at com.android.tools.idea.rendering.RenderTask.getResourceResolver(RenderTask.java:198)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:425)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$52(RenderTask.java:659)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
UPD1: Seem to be an issue.
In your activity.xml file there must be a line as xmlns:app="". Delete it.
There is an error in xml file check that no
android: or xmlns:app=""
Fixed in Android studio 2.2 (Canary) Preview 6 (also see issue).
I've checked online for a solution tried solutions from this page: Error: Suspicious namespace and prefix combination [NamespaceTypo] when I try create Signed APK and also errors in hello world xml but there's no solution. The funny thing is when I try to build a debug of the app or a release for tv and wear everything works well. Error:
(9) Error: Suspicious namespace and prefix combination [NamespaceTypo]
xmlns:app="http://schemas.android.com/tools"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "NamespaceTypo":
Accidental misspellings in namespace declarations can lead to some very
obscure error messages. This check looks for potential misspellings to help track these down.
1 errors, 0 warnings
Layout file part of the code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
A solution to this is very helpful
Instead of what you have on line 3:
xmlns:app="http://schemas.android.com/tools"
Use:
xmlns:tools="http://schemas.android.com/tools"
Please change your namespace
xmlns:app="http://schemas.android.com/tools"
to
xmlns:app="http://schemas.android.com/apk/res-auto"
Fixed the problem...I had been working on the project using Android Studio version 1.0 and got the problem when I updated to version 1.5.1 So all I did is just getting back to the old version and things were okay, I have no idea why this is the case...
You can reproduce those errors by using the tool Analyse->Inspect code in android studio.
in the xml make sure that
xmlns:app="http://schemas.android.com/apk/res-auto"
and
xmlns:tools="http://schemas.android.com/tools".
If you can write like xmlns:app="http://schemas.android.com/tools" ,you will get an error.
I have got a strange situation when I working on my project.I have just run my application once. Then I changed some "android:margin" properties for my XML files. Then the problem came. I ran the project and it crashed. The log says it comes Resource Not Found Exception. Next I tried to export it but it failed to export. I'll post the log and error dialog below.
What have I done:
I reinstalled everything such as eclipse,ADT and SDK. Not work at all. I'm absolutely sure that the resource exists and stays in right position.**
All useful information is needed.
ps: The resource file that not found is an activity layout xml file--my intro activity and I've found the resource id in my R file.
ps: My friends use the same code as me.They don't have any problem.
here's my layout xml file:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fl_base_activity"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/iv_base_wallpaper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#color/trans_cc" />
</FrameLayout>
Try re-building your project , If that doesn't work , delete the 'build' and 'gen' folders of project(you can take a backup elsewhere but remove them from your project folder) and then try running it again.
Let me know if that works.....
I've found why : So stupid fail that there is a resource with no suffix has been add in my project from SVN. It has a same name with correct resource name but without .png, eclipse can't distinguish what's the difference between them. It has no error notice. WTF!
I created a new project in Android Lollipop (API 21) using Studio(64) and Java 7. When I try to add a background on main layout (relative layout) I am getting error
My res folder structure is
NOTE: I have placed 720x1280 img in all drawable* folders.
My XML is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="0dp"
android:background="#drawable/homebackground">
</RelativeLayout>
I tried using PNG / JPG.. but still I am getting same error. Can someone tell where am I going wrong ?
I referred these, but they are not related to my problem or don't solve my problem
Couldn't resolve resource #drawable/backround.png
RelativeLayout "Couldn't resolve resource..." Android
Android image can't convert to drawable
If you are using Android Studio, clicking on File > Invalidate caches/restart should solve the problem.
Inside the Manifest file .....in the field where there is #drawable/homeground replace that with #android:drawable/homeground
I tried "invalidate caches/restart" but it didn't work for me. So to solve this I moved my image(night_sky.jpg) from drawable to mipmap folder and the error was gone.
It worked for me hope it will work for you also 🙂
Image for reference: