I followed the directions on the RootTools usage and run Java as root wiki pages, but when I load my app with the following in onCreate() I get a ClassNotFoundException: com.stericson.RootTools.containers.RootClass:
import com.stericson.RootTools.RootTools;
import com.stericson.RootTools.containers.RootClass;
import com.stericson.RootTools.exceptions.RootDeniedException;
import com.stericson.RootTools.execution.CommandCapture;
import com.stericson.RootTools.execution.JavaCommandCapture;
import com.stericson.RootTools.execution.Shell;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RootTools.debugMode = true; //ON
RootTools.log("roottools is logging");
RootTools.handlerEnabled = false;
Shell shell;
try {
shell = RootTools.getShell(true);
JavaCommandCapture cmd = new JavaCommandCapture(
43,
false,
this,
"com.mycompany.TestActivity.RootToolsTest") {
@Override
public void commandOutput(int id, String line) {
super.commandOutput(id, line);
}
};
shell.add(cmd);
} catch (Exception e) {
e.printStackTrace();
}
...
@RootClass.Candidate
private class RootToolsTest{
public RootToolsTest(){
Log.d("RootToolsTest", "testing a Java class run as root");
}
}
The same thing happened when I tried RootTools' test class com.stericson.RootToolsTests.NativeJavaClass. I've tried a number of configurations for the placement and inclusion of the RootTools.jar file (most notably ensuring that the RootTools jar is checked for export and moved to the top of the order and export list in Eclipse) but the ClassNotFoundException persists. The exact logcat output follows:
06-02 07:27:45.529: D/RootTools v3.4(5165): roottools is logging
06-02 07:27:45.529: D/RootTools v3.4(5165): Starting Root Shell!
06-02 07:27:45.539: D/RootTools v3.4(5165): Starting shell: su
06-02 07:27:46.409: D/RootTools v3.4(5165): CommandHandler not created
06-02 07:27:46.429: D/RootTools v3.4(5165): Executing: dalvikvm -cp /data/data
/com.hdradio.fmdelverrooted/files/anbuild.dex com.android.internal.util.WithFramework
com.stericson.RootTools.containers.RootClass
com.hdradio.fmdelver.core.DelverActivity.RootToolsTest
06-02 07:27:46.749: D/Command(5165): ID: 43, java.lang.ClassNotFoundException:
com.stericson.RootTools.containers.RootClass
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.classForName(Native Method)
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.forName(Class.java:217)
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.forName(Class.java:172)
06-02 07:27:46.769: D/Command(5165): ID: 43,at
com.android.internal.util.WithFramework.main(WithFramework.java:36)
06-02 07:27:46.769: D/Command(5165): ID: 43,at dalvik.system.NativeStart.main(Native
Method)
06-02 07:27:46.769: D/Command(5165): ID: 43, Caused by: java.lang.NoClassDefFoundError:
com/stericson/RootTools/containers/RootClass
06-02 07:27:46.769: D/Command(5165): ID: 43, ... 5 more
06-02 07:27:46.769: D/Command(5165): ID: 43, Caused by: java.lang.ClassNotFoundException:
com.stericson.RootTools.containers.RootClass
06-02 07:27:46.769: D/Command(5165): ID: 43,at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-02 07:27:46.769: D/Command(5165): ID: 43,at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-02 07:27:46.769: D/Command(5165): ID: 43, at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-02 07:27:46.769: D/Command(5165): ID: 43, ... 5 more
06-02 07:27:46.979: D/RootTools v3.4(5165): Command 43 finished.
My .classpath looks like:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="/Users/myhome/devel_resources
/code/RootTools/RootTools-3.4.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con"
path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con"
path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
My development system configuration is as follows: OS: Mac OS X 10.9.2 Eclipse: Kepler ADT: 22.3 RootTools Version: 3.4
and my target platform: Android: 4.1.1 Model: Sony Xperia E C1504 (rooted using SRSRoot and the 'Gandalf' exploit) Firmware: Stock Kernel Xperia E C1505_11.3.A.0.47 (supposed to work for C1504 as well)
Any ideas why Android can't find the com.stericson.RootTools.containers.RootClass class?