Stack Exchange
No syntax errors, still code not working
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();
            }
        }
    });
}}


How do I post it here ? I cant embed an image in comment.

edit int your Question.

I posted the LogCat. Please check.

@Haresh : https://code.google.com/p/roottools/wiki/RootTools

ok it's seems like RootTools class not available so cross check your third party .jar added properly

Are you using any external jar file?

@TheMaverick is it a library project?

Yes. An external jar file - RootTools.jar

i have tested your code with add RootTool Jar and it's working perfectly i think there is probelm on your jar adding. are using Eclispe or Android Studio ?

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.

exact duplicate of this http://stackoverflow.com/questions/22214603/android-java-lang-noclassdeferror-when-using-external-jar. post links instead of duplicating

Working! I had to work around with the Java Build Path. Thank you so much!

@The Maverick : Please accept the answer if above solution worked for you.

@SiddharthVyas http://meta.stackexchange.com/questions/180207/how-to-flag-duplicate-answers. You should not duplicate your answers. Delete the other one as this is accepted

@Raghunandan : I am extremely sorry for this..From now onwards, I will take care of this..Thanks for updating this..

@SiddharthVyas still you should delete the other duplicate. You can keep this as this is accepted and that is not

@Raghunandan I have deleted the previous answers post.Thanks for guiding me.
