The app crashes on device on start, this is the log:
Note I replaced my original ‘com.appname’ with com.myappName
07-20 13:10:05.520 5376 5376 E AndroidRuntime: FATAL EXCEPTION: main
07-20 13:10:05.520 5376 5376 E AndroidRuntime: Process: com.myappName, PID: 5376
07-20 13:10:05.520 5376 5376 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.myappName.MainApplication package com.myappName: java.lang.ClassNotFoundException: Didn't find class "com.myappName.MainApplication" on path: DexPathList[[zip file "/data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/base.apk"],nativeLibraryDirectories=[/data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/lib/x86_64, /data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1463)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1392)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6740)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7892)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myappName.MainApplication" on path: DexPathList[[zip file "/data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/base.apk"],nativeLibraryDirectories=[/data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/lib/x86_64, /data/app/~~jMKAsYSvEjMZSEi2dXirHg==/com.myappName-u02x8yQYisyfG6ITJEv3UA==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.Instrumentation.newApplication(Instrumentation.java:1232)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1455)
07-20 13:10:05.520 5376 5376 E AndroidRuntime: ... 11 more
It used to work fine before both on Mac and here on Linux. After installing fresh Linux distro and cloning the git repository, this started happening
Here is what I did:
- Cloned git repository
- npm install –save-exact
- React Native enviroment / Android is set up properly – no errors regarding that
android/app/build.gradle
defaultConfig {
applicationId "com.myappName"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 20
versionName "2.0"
}
/android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myappName">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Emulator is Resizeable API 33 x86_64
Thanks
2
Answers
I was missing Java files. Fixed the issue by rebuilding android and ios folders with react-native-eject
Make sure to replace package name manually in .java files afterwards.
Check your MainActivity.java and MainApplication.java file’s First line it should be
com.myappName