TransWikia.com

ANDROID: java.lang.RuntimeException: Unable to instantiate activity

Stack Overflow en español Asked by David L on January 19, 2021

Cuando intento compilar mi Android App en Flutter aparece el siguiente error y no tengo la menor idea de cómo leerlo, qué puede ser?

E/AndroidRuntime(18988): FATAL EXCEPTION: main
E/AndroidRuntime(18988): Process: com.aplians.aplians_fish, PID: 18988
E/AndroidRuntime(18988): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.aplians.aplians_fish/com.aplians.aplians_fish.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.aplians.aplians_fish.MainActivity" on path: DexPathList[[zip file "/data/app/com.aplians.aplians_fish-1/base.apk"],nativeLibraryDirectories=[/data/app/com.aplians.aplians_fish-1/lib/arm64, /vendor/lib64, /system/lib64]]
E/AndroidRuntime(18988):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2313)
E/AndroidRuntime(18988):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
E/AndroidRuntime(18988):    at android.app.ActivityThread.access$1200(ActivityThread.java:152)
E/AndroidRuntime(18988):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
E/AndroidRuntime(18988):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18988):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(18988):    at android.app.ActivityThread.main(ActivityThread.java:5538)
E/AndroidRuntime(18988):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18988):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(18988):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:958)
E/AndroidRuntime(18988):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:753)
E/AndroidRuntime(18988): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.aplians.aplians_fish.MainActivity" on path: DexPathList[[zip file "/data/app/com.aplians.aplians_fish-1/base.apk"],nativeLibraryDirectories=[/data/app/com.aplians.aplians_fish-1/lib/arm64, /vendor/lib64, /system/lib64]]
E/AndroidRuntime(18988):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(18988):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(18988):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(18988):    at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
E/AndroidRuntime(18988):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
E/AndroidRuntime(18988):    ... 10 more
E/AndroidRuntime(18988):    Suppressed: java.lang.ClassNotFoundException: com.aplians.aplians_fish.MainActivity
E/AndroidRuntime(18988):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(18988):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(18988):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(18988):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(18988):        ... 13 more
E/AndroidRuntime(18988):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Ayer compiló correctamente e incluso pude obtener el archivo APK previo a la publicación en el PlayStore, sin embargo hoy cuando intento hacer debug desde VS Code me aparece este error en consola y el App se instala en el equipo, pero no es capaz de iniciar.

One Answer

Tienes que revisar lo siguiente :

La estructura de directorios dentro de android

//Si usas java
android/src/main/java/com/aplians/aplians_fish/MainActivity.java

//Si usas kotlin
android/src/main/kotlin/com/aplians/aplians_fish/MainActivity.kt

El nombre del package en la primera linea de la clase MainActivity

package com.aplians.aplians_fish

El AndroidManifest.xml de la carpeta main debe apuntar al package correcto

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aplians.aplians_fish">

El appbuild.gradle debe contener el applicationId correcto

   applicationId "com.aplians.aplians_fish"

Correct answer by diegoveloper on January 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP