• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem in Android Studio

DevHenrik

Lurker
Hey!

Im stuck in Android Studio, emulating my app in genymotion.
I have no errors in my code and when running the app its crashing.

Have also discovered that it crashes after adding my own code, below the auto generated code for the actionbar.

With only the actionbar code it doesn't crash.

What can this be about?

Thansk for help!
 
I have no experience with Genymotion emulators (I like real devices) but if you post your code I may be able to help. Also, if you can let us know the error message... thats a plus :)
 
Thnx!

The A.S doesnt say any errors (red marks), but it does show yellow marks on the hard coded text. Donnu if that can couse it to crash, but I guess it shouldnt.

When I try to run he app I get the msg ".... has unfortunatly stoped". Something like that.

I scratching my head over this, most couse it doesnt show any errors. :/
 
This is the code I added to my project...

// Main program functions starts from here

// Find Id's and set variables
{
final EditText fp = (EditText) findViewById(R.id.fuelprice);
final EditText fC = (EditText) findViewById(R.id.fuelcunsumption);
final EditText drive = (EditText) findViewById(R.id.rangetodrive);
final TextView totalcost = (TextView) findViewById(R.id.totalcost);

Button CalcBtn = (Button) findViewById(R.id.CalcButton);
CalcBtn.setOnClickListener(new View.OnClickListener()

{

@override
public void onClick(View view)
{

// Converting strings to float
String n1 = fp.getText().toString();
float no1 = Float.parseFloat(n1);
String n2 = fC.getText().toString();
float no2 = Float.parseFloat(n2);
String n3 = drive.getText().toString();
float no3 = Float.parseFloat(n3);

// Calculates the floats
float calc = no1 * no2 * no3;

// Converting and prints out the result
String sum = Float.toString(calc);
totalcost.setText(sum);

}
});

Button ResetBtn = (Button) findViewById(R.id.ResetButton);
ResetBtn.setOnClickListener(new View.OnClickListener()

{
// ResetButton Resets the textViews
@override
public void onClick (View view)

{
fp.setText("");
fC.setText("");
drive.setText("");
totalcost.setText("0");
}

});

Since it didnt work out, I made a new project just to try with 1 textview and 1 button.
This is that code:

TextView ShowText = (TextView) findViewById(R.id.testText);

public void PltextBtn(View button) {
ShowText.setText("Test Text");
}

Both cases showed same problem in the genymotion emulator.

Hope to solve this soon!
 
Back
Top Bottom