Device gives error and then restarts after trying to uninstall application

Asked

Viewed 1,050 times

3

I’m having a bug with the application I created, the code is compiling normal and without any error or Warning, and the application is also working on mobile, but when I try to uninstall this application from mobile I get the following message:

"Package installer app stopped."

And on another cell phone of mine, the application displays the following message:

"The system interface application has stopped"

and then the device just reboots.

The two cell phones are Motog 2nd generation, with the android 5.0.2.
I apologise for asking such a comprehensive question but I really have no idea why it was wrong. The program is very simple, so I’m going to send the 3 classes in it:

public class Facts {

    public String[] Mfacts = {
            "Ants stretch when they wake up in the morning.",
            "Ostriches can run faster than horses.",
            "Olympic gold medals are actually made mostly of silver.",
            "Samsung is also a full time weapons manufacturer.",
            "Terrafugia is the world's first flying car."};

    //Save the used facts

    public String getFact() {
        //The button was clicked, so update the fact with a new fact
        String fact = "";
        //Randomly select a fact
        Random randomGenerator = new Random(); // Construct a new random generator

        int randomNumber = randomGenerator.nextInt(Mfacts.length);

        fact = Mfacts[randomNumber];
        return fact;

    }

}
public class Colors {

    public String[] mColors = {
            "#39add1", // light blue
            "#3079ab", // dark blue
            "#c25975", // mauve

    };

    public int getColor() {

        //The button was clicked, so update the fact with a new fact
        String color = "";

        //Randomly select a fact
        Random randomGenerator = new Random(); // Construct a new random generator
        int randomNumber = randomGenerator.nextInt(mColors.length);

        color = mColors[randomNumber];
        int colorAsInt = Color.parseColor(color);

        return colorAsInt;
    }
}
public class MainActivity extends Activity {

    private Facts mFactBook = new Facts();
    private Colors mColorWheel = new Colors();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Declare our View variables and asisgn the Views from the layout file
        final TextView factLabel = (TextView) findViewById(R.id.factTextView);
        final Button showFactButton = (Button) findViewById(R.id.showFactButton);
        final RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);

        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String fact = mFactBook.getFact();

                //Update the label with our dynamic fact
                factLabel.setText(fact);

                int color = mColorWheel.getColor();

                relativeLayout.setBackgroundColor(color);

                showFactButton.setTextColor(color);
            }
        };

        showFactButton.setOnClickListener(listener);
        Toast.makeText(this, "Welcome to Fun Facts!!", Toast.LENGTH_LONG).show();

    }
}

And the build.gradle app:

android {

    compileSdkVersion 22

    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "insight.com.br.funfacts"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:22.2.0'

    compile 'com.google.android.gms:play-services-ads:8.1.0'
}

I’m using the adView to do some tests with the adMob, it is possible that the problem is related to this?

If there’s anything else you need from the code, just let me know.
Thank you very much to those who try to help!

  • 1

    It is good to put the error log that appears in LogCat.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.