W/dalvikvm(21732): threadid=1: thread exiting with uncaught exception (group=0x41d0cda0)
E/Drive.UninstallOperation( 1829): Package still installed com.todos
E/AndroidRuntime(21732): FATAL EXCEPTION: main
E/AndroidRuntime(21732): Process: com.todos, PID: 21732
E/AndroidRuntime(21732): java.lang.RuntimeException: Unable to instantiate application com.todos.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.todos.MyApplication" on path: DexPathList[[zip file "/data/app/com.todos-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.todos-3, /vendor/lib, /system/lib]]
E/AndroidRuntime(21732): at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
E/AndroidRuntime(21732): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4841)
E/AndroidRuntime(21732): at android.app.ActivityThread.access$1600(ActivityThread.java:174)
E/AndroidRuntime(21732): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
E/AndroidRuntime(21732): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(21732): at android.os.Looper.loop(Looper.java:146)
E/AndroidRuntime(21732): at android.app.ActivityThread.main(ActivityThread.java:5731)
E/AndroidRuntime(21732): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(21732): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(21732): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
E/AndroidRuntime(21732): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
E/AndroidRuntime(21732): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(21732): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.todos.MyApplication" on path: DexPathList[[zip file "/data/app/com.todos-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.todos-3, /vendor/lib, /system/lib]]
E/AndroidRuntime(21732): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
E/AndroidRuntime(21732): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/AndroidRuntime(21732): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/AndroidRuntime(21732): at android.app.Instrumentation.newApplication(Instrumentation.java:981)
E/AndroidRuntime(21732): at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
E/AndroidRuntime(21732): ... 11 more
W/ActivityManager( 757): Force finishing activity com.todos/.MainActivity
W/DropBoxManagerService( 757): Dropping: data_app_crash (1781 > 0 bytes)
我的AndroidManifest
如下所示......
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:name="com.todos.MyApplication">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<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>
当我添加com.todos.MyApplication
源文件...
当我在Android Studio中打开项目并导航到MyApplication.java
时,我会看到以下内容......
答案 0 :(得分:3)
您还在面对这个问题吗?
我通过安装干净的APK解决了此问题:
cd android
./gradlew clean
react-native run-android
以上命令将首先转到android文件夹,然后使用./gradlew clean
清理文件夹,然后在项目的根目录中重建react-native run-android
命令。
答案 1 :(得分:-2)
添加属性android:name =&#34; .MyApplication&#34;在您的应用程序标签中,它应该可以解决您的问题
<application
android:name=".MyApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:name="com.todos.MyApplication">