Search code examples
javaandroidreact-nativesamsung-mobile

Didn't find class "LinearLayout" on path: DexPathList for Samsung devices only. (App store build)


We have had an app on the play store for a short amount of time, but none of our developers use Samsung devices, so we haven't been able to test on them. We shared with some Samsung users today, and when they install the app, it crashes immediately without opening. I have received several crash reports through Crashlytics about this, but after investigating, I can't find a solution. The solutions I've found all point out that the class name needs to be capitalized properly, but ours already is.

Here is an overview of the crash logs:

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]]

Essentially: Didn't find class "LinearLayout" on path: DexPathList for the launch screen.

The splash screen works fine on all of our emulators and other physical devices we've tested with so far. But this issue shows up on the Galaxy S6, S8, and S8+ so far.

Here is the launch_screen.xml file. @drawable/launch_screen refers to the png image we use as the splash screen.

<?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>

We show the launch screen by having the initial theme of the application be set to AppTheme.Launcher, which is defined like so:

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>

Does anyone know what causes this issue, or why a particular built-in class wouldn't be found on just one sort of device?


Solution

  • I've found a (rather hacky) solution.

    Essentially, the Samsung device wasn't able to load the layout/* file as the app was opening - e.g. as the splash screen.

    Instead, I switched

    <item name="android:windowBackground">@layout/launch_screen</item>
    

    to the following:

    <item name="android:windowBackground">@drawable/splash_screen</item>
    

    And created a splash_screen drawable xml file which contains the image I wanted to display. This works fine and does not crash the Galaxy device. Interestingly, the Galaxy device is then able to use the @layout/launch_screen file later on once more of the app has opened. There is some extra initialization stuff that happens with react-native, so I continue displaying the splash screen while this happens.

    This basically results in the image displaying more zoomed in than I wish and then "popping" back out to the normally scaled version using the centerCrop parameter once it switches to using the layout file.

    I'm still not sure what the cause of the root issue is, though. The problem seems to be that Samsung Galaxy devices can't load the Layout xml files before the app has been initialized.