No syntax errors, still code not working

143 Views Asked by At

enter image description hereIn 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();
            }
        }
    });
}}
1

There are 1 best solutions below

7
On BEST ANSWER

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.