I'm having a bug with the application I created, the code is compiling normal and no error or warning , and the application is also working on the phone, but when I try to uninstall this application from I get the following message:
"The package installer application has stopped."
And in another mobile phone of mine, the application displays the following message:
"System interface application stopped"
and then the device simply restarts.
Both phones are MotoG 2nd generation, with android 5.0.2
.
I'm sorry for asking such a comprehensive question but I really have no idea why this error occurred. The program is very simple, so I will 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 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 adView
to do some tests with adMob
, is it possible that the problem is related to this?
If you need anything else from the code, just say that I put it here. Many thanks to those who try to help!