Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

Modifying activity main android APP - Error java.lang.ClassNotFoundException: Didn't find class "com.appName.appName.MainActivity"

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...