I have an android app that loads and url (webapp) using WebView, today I was modifying it, adding a splash screen, so I added in the drawable folder throw android studio ( New > Vector Asset ).
Then I open the activity_main.xml do add the tag for that effect.
After that I got errors and in the emulator says that app crashed (AppName keeps stopping). I undo all the changes, save it, and removed the vector throw android studio, and the app keeps crashing.
- Already copied the old activity_main.xml and didn't work. Before I did this the app was working.
- Already rebooted android studio and the pc, still no luck
I'm new to android studio.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</RelativeLayout>
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.appName.appName, PID: 29435
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appName.appName/com.appName.appName.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.appName.appName.MainActivity" on path: DexPathList[[zip file "/data/app/com.appName.appName-IUmYFKEp3QhhYvUCpnyo3Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.appName.appName-IUmYFKEp3QhhYvUCpnyo3Q==/lib/x86, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2843)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.appName.appName.MainActivity" on path: DexPathList[[zip file "/data/app/com.appName.appName-IUmYFKEp3QhhYvUCpnyo3Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.appName.appName-IUmYFKEp3QhhYvUCpnyo3Q==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)?
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)?
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)?
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)?
at android.os.Handler.dispatchMessage(Handler.java:106)?
at android.os.Looper.loop(Looper.java:193)?
at android.app.ActivityThread.main(ActivityThread.java:6669)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)?
Disconnected from the target VM, address: 'localhost:52672', transport: 'socket'
question from:
https://stackoverflow.com/questions/65830614/modifying-activity-main-android-app-error-java-lang-classnotfoundexception-di 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…