我将Android工作室更新到3.0版后,我遇到了一些渲染问题。
我试图像这样更改SDK版本,但仍然无法正常工作。
我的JDK版本是1.8,这是我的一些gradle信息。
compileSdkVersion 26
defaultConfig {
applicationId "com.example.wheathermaster"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
我也试过"清洁项目"和#34;使高速缓存/重新启动失效",但它们都不起作用。
以下是我的错误消息:
渲染期间引发异常
java.lang.NullPointerException
at android.graphics.BidiRenderer.getScriptFont(BidiRenderer.java:290)
at android.graphics.BidiRenderer.getScriptRuns(BidiRenderer.java:280)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:133)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:108)
at android.graphics.Paint_Delegate.measureText(Paint_Delegate.java:1318)
at android.graphics.Paint_Delegate.nGetTextAdvances(Paint_Delegate.java:975)
at android.graphics.Paint_Delegate.nGetRunAdvance(Paint_Delegate.java:1154)
at android.graphics.Paint.nGetRunAdvance(Paint.java)
at android.graphics.Paint.getRunAdvance(Paint.java:2734)
at android.graphics.Paint.getRunAdvance(Paint.java:2766)
at android.text.TextLine.getRunAdvance(TextLine.java:732)
at android.text.TextLine.handleText(TextLine.java:778)
at android.text.TextLine.handleRun(TextLine.java:1018)
at android.text.TextLine.measureRun(TextLine.java:417)
at android.text.TextLine.measure(TextLine.java:307)
at android.text.TextLine.metrics(TextLine.java:281)
at android.text.BoringLayout.isBoring(BoringLayout.java:294)
at android.widget.TextView.makeSingleLayout(TextView.java:7960)
at android.widget.TextView.makeNewLayout(TextView.java:7853)
at android.widget.TextView.assumeLayout(TextView.java:7754)
at android.widget.TextView.onDraw(TextView.java:6807)
at android.view.View.draw(View.java:19192)
at android.view.View.draw(View.java:19062)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19060)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19195)
at android.view.View.draw(View.java:19062)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19060)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19060)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19060)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4236)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
at android.view.View.draw(View.java:19195)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:403)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:541)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:424)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)
at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:757)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
onMeasure:
java.lang.NullPointerException
at android.graphics.BidiRenderer.getScriptFont(BidiRenderer.java:290)
at android.graphics.BidiRenderer.getScriptRuns(BidiRenderer.java:280)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:133)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:108)
at android.graphics.Paint_Delegate.measureText(Paint_Delegate.java:1318)
at android.graphics.Paint_Delegate.nGetTextAdvances(Paint_Delegate.java:975)
at android.graphics.Paint_Delegate.nGetRunAdvance(Paint_Delegate.java:1154)
at android.graphics.Paint.nGetRunAdvance(Paint.java)
at android.graphics.Paint.getRunAdvance(Paint.java:2734)
at android.graphics.Paint.getRunAdvance(Paint.java:2766)
at android.text.TextLine.getRunAdvance(TextLine.java:732)
at android.text.TextLine.handleText(TextLine.java:778)
at android.text.TextLine.handleRun(TextLine.java:1018)
at android.text.TextLine.measureRun(TextLine.java:417)
at android.text.TextLine.measure(TextLine.java:307)
at android.text.TextLine.metrics(TextLine.java:281)
at android.text.BoringLayout.isBoring(BoringLayout.java:294)
at android.widget.TextView.onMeasure(TextView.java:8125)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22071)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1148)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:687)
at android.view.View.measure(View.java:22071)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:958)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure_Original(ContentFrameLayout.java:139)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure_Original(ActionBarOverlayLayout.java:400)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java)
at android.view.View.measure(View.java:22071)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:22071)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:590)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:343)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678)
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)
答案 0 :(得分:0)
有时android studio无法预览布局,因此将设计器预览中的Android版本 更改为当前版本取决于您的清单。渲染问题导致您的设计器预览使用的API级别高于当前的Android API级别。
快乐的编码!!
答案 1 :(得分:0)
我有同样的问题。我将 font.xml 更改为旧版,然后解决了。 我不知道导致此错误的字体是什么,但这对我有用。
答案 2 :(得分:0)
对于迟到的答案感到抱歉,但是将你的IDE AndroidS更新为3.2 shoud解决了你的问题。干杯! :)
答案 3 :(得分:0)
只需关闭Android Studio,删除.android
和.gradle
文件,然后再次打开android studio。问题应该解决。