Description
I got runtime error as follow:
FATAL EXCEPTION: main Process: com.example.application, PID: 12628 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.application/com.example1.plugin.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example1.plugin.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/lib/arm, /data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/product/lib]] at android.app.ActivityThread.performLaunchActivity(Unknown Source:670) at android.app.ActivityThread.handleLaunchActivity(Unknown Source:47) at android.app.servertransaction.LaunchActivityItem.execute(Unknown Source:63) at android.app.servertransaction.TransactionExecutor.executeCallbacks(Unknown Source:77) at android.app.servertransaction.TransactionExecutor.execute(Unknown Source:73) at android.app.ActivityThread$H.handleMessage(Unknown Source:43) at android.os.Handler.dispatchMessage(Unknown Source:19) at android.os.Looper.loop(Unknown Source:242) at android.app.ActivityThread.main(Unknown Source:98) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11) at com.android.internal.os.ZygoteInit.main(Unknown Source:275) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example1.plugin.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/lib/arm, /data/app/com.example.application-W9VpbiNaMzP9jEiSHXvWhA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/product/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.AppComponentFactory.instantiateActivity(Unknown Source:0) at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45) at android.app.Instrumentation.newActivity(Unknown Source:22) at android.app.ActivityThread.performLaunchActivity(Unknown Source:88) ... 11 more
im using this method to launch directly when classloader running:
try { Class<?> apkActivity = getClassLoader().loadClass("com.example.application.MainActivity"); Intent intent = new Intent(); intent.setClass(MainActivity.this, apkActivity); startActivity(intent); } catch (ClassNotFoundException e) { e.printStackTrace(); }
my manifest:
<application android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:banner="@drawable/app_banner" android:debuggable="false" android:icon="@mipmap/app_icon" android:label="@string/app_name" android:name="com.example.application.MyApplication" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/app_icon_round"> <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:exported="true" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.example1.plugin.MainActivity" android:resizeableActivity="false" android:screenOrientation="sensorLandscape"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter>
but why the dex load onto /data/app/packagename/ not Android,ldata/packagename/files/myApk.apk inside the myApk
thanks before