Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjohn DOe
27,897 PointsRendering Problems Couldn't resolve resource @drawable/bgradient Failed to convert @drawable/bgradient into a drawable
I can't seem to resolve this issue even though it's the exact same file as the video:
'''<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#f9d34c"
android:endColor="#f25019"
android:angle="270"/>
</shape>'''
How can I solve this?
Here's the Stack Trace:
java.lang.NumberFormatException: Color value '@drawable/bg_gradient' must start with # at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:79) at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:270) at android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:729) at android.widget.ImageView.<init>(ImageView.java:152) at android.widget.ImageView.<init>(ImageView.java:140) at android.widget.ImageView.<init>(ImageView.java:136) at sun.reflect.GeneratedConstructorAccessor81.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at android.view.LayoutInflater.createView(LayoutInflater.java:619) at android.view.BridgeInflater.onCreateView(BridgeInflater.java:107) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:149) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498) at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72) at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610) at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607) at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594) at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:351) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 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)
1 Answer
Evan Demaris
64,262 PointsHi Oindril,
I'd recommend cleaning your project. If that doesn't do the trick, try closing Android Studio and restarting it. Else, update XML;
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#f9d34c"
android:endColor="#f25019"
android:angle="270" />
</shape>
Hope that helps!
john DOe
27,897 PointsI was using the exact same code, so I cleaned, rebuilded, gradle synced, closed and opened up the editor, and nothing worked. I restarted my computer, and now it freaking works! The ol' turn it off and turn it on again never fails...
Thank you!
Philip Gales
15,193 Pointshaha Oindril....EVERY time.
Philip Gales
15,193 PointsPhilip Gales
15,193 PointsCan you link the video?