某些手机(例如Samsung S6或S7)无法启动我的Android webview应用程序。这是我从谷歌游戏商店得到的:
java.lang.RuntimeException:
at android.view.DisplayListCanvas.throwIfCannotDraw (DisplayListCanvas.java:260)
at android.graphics.Canvas.drawBitmap (Canvas.java:1420)
at android.graphics.drawable.BitmapDrawable.draw (BitmapDrawable.java:545)
at android.widget.ImageView.onDraw (ImageView.java:1286)
at android.view.View.draw (View.java:18318)
at android.view.View.updateDisplayListIfDirty (View.java:17296)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.draw (View.java:18321)
at com.android.internal.policy.DecorView.draw (DecorView.java:919)
at android.view.View.updateDisplayListIfDirty (View.java:17296)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:698)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:806)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3128)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:2924)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2516)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1515)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7091)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:927)
at android.view.Choreographer.doCallbacks (Choreographer.java:702)
at android.view.Choreographer.doFrame (Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:913)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6682)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
这似乎是我的闪屏,就是这样:
activity_main.xml中:
//splashscreen fullscreen
<ImageView
android:id="@+id/splash1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:screenOrientation="portrait"
android:visibility="visible"
android:src="@drawable/redsplashscreen"
/>
//shows the webview fullscreen
<WebView
android:id="@+id/web1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
MainActivity.java片段:
boolean splashFinished = false;
@Override
public void onPageFinished(WebView view, String url) {
//loads splashscreen once till website is loaded
if (!splashFinished) {
//hides loading image
findViewById(R.id.splash1).setVisibility(View.GONE);
//shows webview
findViewById(R.id.web1).setVisibility(View.VISIBLE);
splashFinished = true;
}
这里的一些人说我必须将图像从“drawable”文件夹移动到“drawable-xxhd”,我尝试了,但是当我想创建一个APK时,android studio会将其移回并更改代码xml。
BTW图像不是很大,我将大小从1.7MB改为0.7MB。
答案 0 :(得分:0)
在我的情况下,有些手机无法处理大飞溅图像文件。 我是1.xMB,在减小文件大小后,不再崩溃了。
缩小文件大小。
答案 1 :(得分:0)
我有一个解决方案:在android studio中我制作了“drawable-xxhdpi”文件夹(右击“res” - &gt; new - &gt;目录)。我将相同的splashscreen图像放在此文件夹中。这样,它不会改变aactivity_main.xml的任何内容。