我们在Play商店中使用了很短的时间,但是我们的开发人员都不使用三星设备,因此我们无法对其进行测试。今天我们与一些三星用户分享了信息,当他们安装该应用程序时,它立即崩溃而没有打开。我通过Crashlytics收到了一些有关此问题的崩溃报告,但是经过调查,我找不到解决方案。我发现的所有解决方案都指出,类名需要正确地大写,但是我们已经是大写了。
以下是崩溃日志的概述:
Exception java.lang.RuntimeException: Unable to start activity
ComponentInfo {com.zonderstudios.zonder/com.zonderstudios.zonder.MainActivity}:
android.content.res.Resources$NotFoundException: Drawable
com.zonderstudios.zonder:layout/launch_screen with resource ID
#0x7f04002d
Caused by android.content.res.Resources$NotFoundException: Drawable
com.zonderstudios.zonder:layout/launch_screen with resource ID #0x7f04002d
Caused by android.content.res.Resources$NotFoundException: File
res/layout/launch_screen.xml from drawable resource ID #0x7f04002d
Caused by android.view.InflateException: Class not found LinearLayout
Caused by java.lang.ClassNotFoundException: Didn't find class
"LinearLayout" on path: DexPathList[[zip file
"/data/app/com.zonderstudios.zonder-
R0tFS_4BNjS6q0znS27jPw==/base.apk"],nativeLibraryDirectories= .
[/data/app/com.zonderstudios.zonder-R0tFS_4BNjS6q0znS27jPw==/lib/arm,
/data/app/com.zonderstudios.zonder-
R0tFS_4BNjS6q0znS27jPw==/base.apk!/lib/armeabi-v7a, /system/lib,
/system/vendor/lib]]
本质上:在启动屏幕的路径:DexPathList上找不到类“ LinearLayout”。
初始屏幕在到目前为止我们测试过的所有模拟器和其他物理设备上都可以正常运行。但是到目前为止,这个问题在Galaxy S6,S8和S8 +上都可以看到。
这是launch_screen.xml
文件。 @ drawable / launch_screen是指我们用作初始屏幕的png图像。
<?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">
<ImageView
android:id="@+id/launch_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/launch_screen"
/>
</LinearLayout>
我们通过将应用程序的初始主题设置为AppTheme.Launcher
来显示启动屏幕,其定义如下:
styles.xml
:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.Launcher">
<item name="android:windowBackground">@layout/launch_screen</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
</style>
</resources>
有人知道导致此问题的原因,还是为什么只在一种设备上找不到特定的内置类?
答案 0 :(得分:0)
我找到了一个(相当hacky)的解决方案。
从本质上讲,三星设备无法在打开应用程序时加载layout/*
文件-例如,作为启动屏幕。
相反,我切换了
<item name="android:windowBackground">@layout/launch_screen</item>
到以下:
<item name="android:windowBackground">@drawable/splash_screen</item>
并创建了一个包含我要显示的图像的splash_screen可绘制xml文件。这可以正常工作,并且不会使Galaxy设备崩溃。有趣的是,Galaxy设备随后可以在再次打开该应用后使用@layout/launch_screen
文件。 react-native还会发生一些额外的初始化工作,因此在发生这种情况时,我将继续显示初始屏幕。
这基本上导致图像显示比我期望的更大的缩放比例,然后在切换到使用布局文件后,使用centerCrop
参数“弹出”回到正常缩放的版本。
尽管如此,我仍然不确定根本原因是什么。问题似乎是三星Galaxy设备无法在应用初始化之前加载Layout xml文件。