Skip to content

java.lang.ClassNotFoundException when using Java.registerClass #49

Description

@ali-alidoust

I get the following error when I use Java.registerClass:
The device is an ARMv7 running Android 4.4.4

Error: java.lang.ClassNotFoundException: Didn't find class "com.example.MyRunnable" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]', u'fileName': u'frida/node_modules/frida-java/lib/env.js', u'lineNumber': 218, u'type': u'error', u'stack': u'Error: java.lang.ClassNotFoundException: Didn't find class "com.example.MyRunnable" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at frida/node_modules/frida-java/lib/env.js:218
    at ensureClass (frida/node_modules/frida-java/lib/class-factory.js:435)
    at frida/node_modules/frida-java/lib/class-factory.js:119
    at registerClass (frida/node_modules/frida-java/lib/class-factory.js:1637)
    at script1.js:11
    at frida/node_modules/frida-java/lib/vm.js:39
    at frida/node_modules/frida-java/index.js:281
    at script1.js:15'}

Here is the code that produces the error:

Java.perform(function() {
    var Runnable = Java.use('java.lang.Runnable');
    var MyRunnable = Java.registerClass({
        name: 'com.example.MyRunnable',
        implements: [Runnable],
        methods: {
            'run': function() {
                console.log('Hello!!!');
            }
        }
    });

    var runnable = MyRunnable.$new();
    runnable.run();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions