Search code examples
javaandroidclassnotfoundexception

ClassNotFoundException with XposedBridge


I'm writing an Xposed module (which runs), and I just added an activity to it, so I could tweak some settings in the application.

I created an Activity the regular Android way, and added it to my manifest (the package name is correct). I also added the class name to my xposed_init file.

I still get this in my logcat:

07-02 15:50:33.275: E/AndroidRuntime(2505): Caused by: java.lang.ClassNotFoundException: Didn't find class "tweaks.vinit.xdictionary.DictSettings" on path: DexPathList[[zip file "/data/data/de.robv.android.xposed.installer/bin/XposedBridge.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

What could the problem be?

Edit: here's a more detailed log.

07-02 18:33:25.485: W/Xposed(16780): Package name for /data/app/com.zst.xposed.xuimod-1.apk had to be retrieved via parser
07-02 18:33:25.489: W/ActivityThread(16780): Application tweaks.vinit.xdictionary can be debugged on port 8100...
07-02 18:33:25.491: D/AndroidRuntime(16780): Shutting down VM
07-02 18:33:25.491: W/dalvikvm(16780): threadid=1: thread exiting with uncaught exception (group=0x41632d40)
07-02 18:33:25.493: E/AndroidRuntime(16780): FATAL EXCEPTION: main
07-02 18:33:25.493: E/AndroidRuntime(16780): Process: tweaks.vinit.xdictionary, PID: 16780
07-02 18:33:25.493: E/AndroidRuntime(16780): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tweaks.vinit.xdictionary/tweaks.vinit.xdictionary.TempClass}: java.lang.ClassNotFoundException: Didn't find class "tweaks.vinit.xdictionary.TempClass" on path: DexPathList[[zip file "/data/data/de.robv.android.xposed.installer/bin/XposedBridge.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2135)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.os.Handler.dispatchMessage(Handler.java:102)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.os.Looper.loop(Looper.java:136)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread.main(ActivityThread.java:5102)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at java.lang.reflect.Method.invokeNative(Native Method)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at java.lang.reflect.Method.invoke(Method.java:515)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at dalvik.system.NativeStart.main(Native Method)
07-02 18:33:25.493: E/AndroidRuntime(16780): Caused by: java.lang.ClassNotFoundException: Didn't find class "tweaks.vinit.xdictionary.TempClass" on path: DexPathList[[zip file "/data/data/de.robv.android.xposed.installer/bin/XposedBridge.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
07-02 18:33:25.493: E/AndroidRuntime(16780):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.Instrumentation.newActivity(Instrumentation.java:1084)
07-02 18:33:25.493: E/AndroidRuntime(16780):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2126)
07-02 18:33:25.493: E/AndroidRuntime(16780):    ... 12 more

Edit 2: also, TempClas (second log) is the same as DictSettings (first log), just a different name. Here's the code:

package tweaks.vinit.xdictionary;

import android.app.Activity;
import android.os.Bundle;

public class TempClass extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.templayout);
    }

}

Edit 3: aaand, here's my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tweaks.vinit.xdictionary"
    android:versionCode="1"
    android:versionName="0.9.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:hasCode="false"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="tweaks.vinit.xdictionary.TempClass"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="xposedmodule"
            android:value="true" />
        <meta-data
            android:name="xposeddescription"
            android:value="App that searches for the definition of your selection on dictionary.com" />
        <meta-data
            android:name="xposedminversion"
            android:value="30" />
    </application>

</manifest>

Solution

  • If DictSettings uses any Xposed-specific stuff, using it in your Activity won't work, as the Xposed classes are only available in the module part of your APK, not the 'normal app' part!

    If you look closely in your logcat, you may notice dalvikvm complaining about a missing base class of DictSettings, which then causes the ClassNotFoundException!

    Edit: why are you using hasCode=false? Try changing it to true!