我目前正在应用程序中测试由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很新,我现在很困惑:(
如果有人可以帮助我,我将不胜感激!
答案 0 :(得分: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;
它对我有用,希望它对你有用!
答案 1 :(得分:2)
在Eclipse中,右键单击您的项目,导航到“Build Path”,然后“配置构建路径” 现在选择“添加外部罐子” 导航到您下载的RootTools .jar文件并选择它。 导航到“订购和导出”,确保在库旁边勾选该框,然后将其移至列表顶部。 选择“确定”
完成