我的启动画面在模拟器中工作,但是在物理设备上它会崩溃。可能是什么事?
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
</resources>
splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/splash_screen"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>
</layer-list>
以上是我为模拟器中使用的启动画面添加的内容。如何使用物理设备(Samsung S8)调试崩溃。
的AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koolbusiness">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
我能够从谷歌应用程序控制台生成这个堆栈跟踪(不会忘记搜索USB驱动程序)。
37 minutes ago on app version 7
Samsung Galaxy S8 (dreamlte), 4096MB RAM, Android 8.0
Report 1
java.lang.RuntimeException:
at android.view.DisplayListCanvas.throwIfCannotDraw (DisplayListCanvas.java:229)
at android.view.RecordingCanvas.drawBitmap (RecordingCanvas.java:97)
at android.graphics.drawable.BitmapDrawable.draw (BitmapDrawable.java:529)
at android.view.View.getDrawableRenderNode (View.java:20627)
at android.view.View.drawBackground (View.java:20563)
at android.view.View.draw (View.java:20343)
at com.android.internal.policy.DecorView.draw (DecorView.java:979)
at android.view.View.updateDisplayListIfDirty (View.java:19297)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:686)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:800)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3447)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3234)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2769)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1738)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7745)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
at android.view.Choreographer.doCallbacks (Choreographer.java:723)
at android.view.Choreographer.doFrame (Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
at android.os.Handler.handleCallback (Handler.java:789)
at android.os.Handler.dispatchMessage (Handler.java:98)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6938)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
答案 0 :(得分:1)
我在我的应用中使用相同的方法创建了一个启动画面并且对我有用,尝试这些更改并让我知道。
styles.xml - 删除parent="AppTheme"
部分,使它看起来像这样
<style name="SplashTheme">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
// use a color here instead like the line below
<item android:drawable="@color/white"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>
</layer-list>
清单 - 使用"@style/SplashTheme"
作为应用主题,并从主要活动中删除android:theme="@style/SplashTheme"
行。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koolbusiness">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/SplashTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"
/>
</application>
</manifest>