在JavaCommandCapture中由RootTools抛出的ClassNotFoundException

时间:2014-02-27 22:05:37

标签: java android eclipse roottools

我按照RootTools usagerun Java as root wiki页面上的说明操作,但是当我在onCreate()中加载我的应用程序时,我得到一个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");
    }
}

当我尝试使用RootTools的测试类com.stericson.RootToolsTests.NativeJavaClass时,同样的事情发生了。我已经尝试了许多配置来放置和包含RootTools.jar文件(最值得注意的是确保RootTools jar被检查导出并移动到Eclipse中的顺序和导出列表的顶部)但ClassNotFoundException仍然存在。确切的logcat输出如下:

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.

我的.classpath看起来像:

<?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>

我的开发系统配置如下: 操作系统:Mac OS X 10.9.2 Eclipse:开普勒 ADT:22.3 RootTools版本:3.4

和我的目标平台: Android:4.1.1 型号:Sony Xperia E C1504(根据SRSRoot和'Gandalf'漏洞利用) 固件:库存内核Xperia E C1505_11.3.A.0.47(也适用于C1504)

为什么Android无法找到com.stericson.RootTools.containers.RootClass类?

1 个答案:

答案 0 :(得分:0)

发生在我身上,jar文件已损坏且.class文件实际上不存在。确切地说是异常告诉你的。