没有语法错误,仍code不工作 [英] No syntax errors, still code not working
本文介绍了没有语法错误,仍code不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的code,我尝试使用roottools检查root权限。目前还没有任何语法错误,但每当我点击检查root用户访问按钮,我得到一个应用程序已意外停止的消息。请帮助。
包com.maverick.checkforroot;进口com.stericson.RootTools.RootTools;进口android.app.Activity;
进口android.os.Bundle;
进口android.view.View;
进口android.view.View.OnClickListener;
进口android.widget.Button;
进口android.widget.TextView;
进口android.widget.Toast;公共类MainActivity延伸活动{@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main); TextView的制造商=(的TextView)findViewById(R.id.Manufacturer);
字符串马努= android.os.Build.MANUFACTURER ;;
Manufacturer.setText(马努); TextView的TV1 =(的TextView)findViewById(R.id.tv1);
弦模型= android.os.Build.MODEL;
tv1.setText(模型); TextView的产品=(的TextView)findViewById(R.id.Product);
字符串临= android.os.Build.PRODUCT ;;
Product.setText(专业版); 按钮根=(按钮)findViewById(R.id.Root);
Root.setOnClickListener(新OnClickListener(){ @覆盖
公共无效的onClick(查看为arg0){
如果(RootTools.isAccessGiven()){
Toast.makeText(MainActivity.this,根访问!,Toast.LENGTH_LONG).show();
}
其他{
Toast.makeText(MainActivity.this,无根的访问!,Toast.LENGTH_LONG).show();
}
}
});
}}
解决方案
试试这个:
转到项目/属性/ Java构建路径/订单和出口标签 - 确保有一个在Android的依赖关系的正面和支持库进行检查,如果你使用it.Mark所有的复选框,并单击Apply和清理项目
In the code below, I tried to check root access using roottools. There aren't any syntax errors but whenever I click the "Check Root Access" button, I get an "application has stopped unexpectedly" message. Please help.
package com.maverick.checkforroot;
import com.stericson.RootTools.RootTools;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView Manufacturer = (TextView) findViewById(R.id.Manufacturer);
String Manu = android.os.Build.MANUFACTURER;;
Manufacturer.setText(Manu);
TextView tv1 = (TextView) findViewById(R.id.tv1);
String Model = android.os.Build.MODEL;
tv1.setText(Model);
TextView Product = (TextView) findViewById(R.id.Product);
String Pro = android.os.Build.PRODUCT;;
Product.setText(Pro);
Button Root = (Button) findViewById(R.id.Root);
Root.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (RootTools.isAccessGiven()) {
Toast.makeText(MainActivity.this,"Root Access!", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(MainActivity.this,"No Root Access!", Toast.LENGTH_LONG).show();
}
}
});
}}
解决方案
Try this:
Go to Project/Properties/Java Build Path/Order and Export tab -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
这篇关于没有语法错误,仍code不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文