- Android version: 4.3
- Frida client version: 10.6.18
- Frida server version: frida-server-10.6.18-android-arm
Using Java.choose() directly outputs Error: VM::GetEnv failed: -2, but using it a second time with a small delay works. Here is a snippet of code showing the issue:
function choose(className) {
Java.perform(function() {
Java.choose(className, {
'onMatch': function(instance) {
console.log('[*] Instance found: ' + instance.toString());
},
'onComplete': function() {},
});
})
};
choose('android.view.View');
setTimeout(function() {
choose(className);
}, 100);
Here is the output when run using frida -U 25390 -l script.js
Error: VM::GetEnv failed: -2
at e (frida/node_modules/frida-java/lib/result.js:7)
at frida/node_modules/frida-java/lib/vm.js:72
at frida/node_modules/frida-java/lib/class-factory.js:339
at frida/node_modules/frida-java/lib/class-factory.js:394
[*] Instance found: android.view.View{4249de38 V.ED.... ........ 0,95-720,96 #7f0e0cd5 app:id/bny}
[*] Instance found: android.view.View{42827d70 V.ED.... ........ 0,93-720,94 #7f0e0ce8 app:id/bog}
[*] Instance found: android.view.View{42bdbba8 I.ED.... ......I. 180,0-360,546}
[*] Instance found: android.view.View{42bdbd40 I.ED.... ......I. 360,0-540,546}
[*] Instance found: android.view.View{42bdbed8 I.ED.... ......I. 540,0-720,546}
The first call to choose() is necessary, else the second call fails with "Error: VM::GetEnv failed: -2". Making the second call directly, without setTimeout(), also gives "Error: VM::GetEnv failed: -2".
Using
Java.choose()directly outputsError: VM::GetEnv failed: -2, but using it a second time with a small delay works. Here is a snippet of code showing the issue:Here is the output when run using
frida -U 25390 -l script.jsThe first call to
choose()is necessary, else the second call fails with "Error: VM::GetEnv failed: -2". Making the second call directly, withoutsetTimeout(), also gives "Error: VM::GetEnv failed: -2".