4

我目前正在一个应用程序中测试由 stericson 制作的 roottools jar/库,但每次应用程序加载它都会强制关闭。

这是代码:

package com.liamwli.root;

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

import android.widget.Toast;

import com.stericson.RootTools.*;

public class root_test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (RootTools.isBusyboxAvailable()) {
            setContentView(R.layout.main);
        } else {
            RootTools.offerBusyBox(this);
        }

        if (RootTools.isRootAvailable()) {
            Toast liam = Toast.makeText(this, "Root Available",
                    Toast.LENGTH_SHORT);
            liam.show();
        } else {
            // do something else
        }

    }
}

这是logcat:

04-04 21:44:47.009: I/Process(6622): Sending signal. PID: 6622 SIG: 9
04-04 21:45:40.859: I/dalvikvm(6722): Could not find method com.stericson.RootTools.RootTools.isBusyboxAvailable, referenced from method com.liamwli.root.root_test.onCreate
04-04 21:45:40.859: W/dalvikvm(6722): VFY: unable to resolve static method 16: Lcom/stericson/RootTools/RootTools;.isBusyboxAvailable ()Z
04-04 21:45:40.859: D/dalvikvm(6722): VFY: replacing opcode 0x71 at 0x0003
04-04 21:45:40.859: D/AndroidRuntime(6722): Shutting down VM
04-04 21:45:40.859: W/dalvikvm(6722): threadid=1: thread exiting with uncaught exception (group=0x40ac21f8)
04-04 21:45:40.869: E/AndroidRuntime(6722): FATAL EXCEPTION: main
04-04 21:45:40.869: E/AndroidRuntime(6722): java.lang.NoClassDefFoundError: com.stericson.RootTools.RootTools
04-04 21:45:40.869: E/AndroidRuntime(6722):     at com.liamwli.root.root_test.onCreate(root_test.java:16)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.Activity.performCreate(Activity.java:4465)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.os.Looper.loop(Looper.java:137)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at android.app.ActivityThread.main(ActivityThread.java:4424)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at java.lang.reflect.Method.invokeNative(Native Method)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at java.lang.reflect.Method.invoke(Method.java:511)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-04 21:45:40.869: E/AndroidRuntime(6722):     at dalvik.system.NativeStart.main(Native Method)

我对android很陌生,现在我很困惑:(

如果有人可以帮助我,我将不胜感激!

4

2 回答 2

2

在 Eclipse 中,右键单击您的项目,导航到“Build Path”,然后导航到“configure build path” 现在选择“add External Jar” 导航到您下载的 RootTools .jar 文件并选择它。 导航到“订购和导出”,确保选中库旁边的框,然后将其移至列表顶部。 选择“确定”完成

于 2013-04-18T09:05:29.690 回答
2

我通过分离进口解决了这个问题。代替:

import com.stericson.RootTools.*;

我只使用/需要:

import com.stericson.RootTools.RootTools;

如果需要,请尝试单独添加其他人。

import com.stericson.RootTools.Mount;
import com.stericson.RootTools.Permissions;
import com.stericson.RootTools.RootToolsException;
import com.stericson.RootTools.Symlink;
import com.stericson.RootTools.SanityCheckRootTools;

它对我有用,希望对你有用!

于 2012-04-25T08:42:15.777 回答