"Force Quit" Error when trying to run in emulator

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

"Force Quit" Error when trying to run in emulator

Postby Kastagire » Tue Apr 29, 2008 9:21 pm

:?:

Hey All,
I have been working on the DroidDraw currency conversion calculator to try to get the hang of Android, but I keep getting a weird error when it goes to display on the emulator. The error states:

Application Error: com.android.CurrencyConverter

An error has occurred in com. android.CurrencyConverter. Unable to instantiate activity component info{com. android.CurrencyConverter/com.android.CurrencyConverter.currencycalc} java.land.Class not found exception:

I have attached a screenshot of the error as well.

The Code is as follows:

package com.android.CurrencyConverter;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import java.lang.*;

public class CurrencyConverter extends Activity implements OnClickListener {
TextView dollars;
TextView euros;
RadioButton dtoe;
RadioButton etod;
Button convert;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.main);

dollars = (TextView)this.findViewById(R.id.dollars);
euros = (TextView)this.findViewById(R.id.widget161);

dtoe = (RadioButton)this.findViewById(R.id.dtoe);
dtoe.setChecked(true);
etod = (RadioButton)this.findViewById(R.id.etoe);

convert = (Button)this.findViewById(R.id.widget36);
convert.setOnClickListener(this);
}

public void onClick(View v) {
if (dtoe.equals(true)) {
convertDollarsToEuros();
}
if (etod.equals(true)) {
convertEurosToDollars();
}
}

public void convertDollarsToEuros() {
double val = Double.parseDouble(dollars.getText().toString());
// in a real app, we'd get this off the 'net
euros.setText(Double.toString(val*0.67));
}

public void convertEurosToDollars() {
double val = Double.parseDouble(euros.getText().toString());
// in a real app, we'd get this off the 'net
dollars.setText(Double.toString(val/0.67));
}
}


The XML code is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget156"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/widget37"
android:layout_width="wrap_content"
android:layout_height="-119px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
>
</LinearLayout>
<LinearLayout
android:id="@+id/widget157"
android:layout_width="200px"
android:layout_height="225px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
>
<TextView
android:id="@+id/widget158"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dollars"
android:textStyle="bold"
>
</TextView>
<EditText
android:id="@+id/dollars"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="EditText"
android:textSize="18sp"
>
</EditText>


Any help you can give me to figure this out will be appreciated!

-Greg
Attachments
androiderror.JPG
androiderror.JPG (45.63 KiB) Viewed 3220 times
androiderror.JPG
androiderror.JPG (45.63 KiB) Viewed 3220 times
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Top

AndroidManifest

Postby cadlg » Tue Apr 29, 2008 9:46 pm

I think it would be useful to see your AndroidManifest file.

Regards,

cadlg
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Postby Kastagire » Tue Apr 29, 2008 10:24 pm

Here is the manifiest... Thanks for the fast response!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.CurrencyConverter">
<application android:icon="@drawable/icon">
<activity android:name=".currencycalc" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Postby cadlg » Tue Apr 29, 2008 10:32 pm

Hi Kastagire

In your AndroidManifest you have declared an activity called "currencycalc" but your activity seems to be called "CurrencyConverter "

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class CurrencyConverter extends Activity implements OnClickListener {
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


this:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <activity android:name=".currencycalc" android:label="@string/app_name">
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


should be:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <activity android:name=".CurrencyConverter" android:label="@string/app_name">
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Regards,

cadlg
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Postby Kastagire » Tue Apr 29, 2008 10:34 pm

cool, so can I just go into the manifest file and change it to match?
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Postby cadlg » Tue Apr 29, 2008 10:37 pm

Yes, you can edit it as you want.
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Top

Postby Kastagire » Wed Apr 30, 2008 10:06 pm

Awesome... So I got it to dipslay on the emulator, but now it seems I cannot get the program to work. I added some code that should uncheck a radio button if the other is selected, but I cannot get that to work either. Do you think this has something to do with the emulator or just bad code? This is a tutorial from DroidDraw, so I would think it would work. Any ideas?

package com.android.Currency;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;


public class Currency extends Activity implements OnClickListener {
TextView dollars;
TextView euros;
RadioButton dtoe;
RadioButton etod;
Button convert;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.main);

dollars = (TextView)this.findViewById(R.id.dollars);
euros = (TextView)this.findViewById(R.id.euros);

dtoe = (RadioButton)this.findViewById(R.id.dtoe);

etod = (RadioButton)this.findViewById(R.id.etoe);

convert = (Button)this.findViewById(R.id.convert);
convert.setOnClickListener(this);
}

public void onClick(View v) {
if (dtoe.equals(true)) {
etod.setChecked(false);
convertDollarsToEuros();
}
if (etod.equals(true)) {
dtoe.setChecked(false);
convertEurosToDollars();

}
}

public void convertDollarsToEuros() {
double val = Double.parseDouble(dollars.getText().toString());
// in a real app, we'd get this off the 'net
euros.setText(Double.toString(val*0.67));
}

public void convertEurosToDollars() {
double val = Double.parseDouble(euros.getText().toString());
// in a real app, we'd get this off the 'net
dollars.setText(Double.toString(val/0.67));
}
}
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Postby cadlg » Wed Apr 30, 2008 10:19 pm

As far as I know, the check-uncheck is automatic when the RadioButtons are part of a RadioGroup

cadlg
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Postby Kastagire » Wed Apr 30, 2008 10:45 pm

it should be, but it was not working correctly. I thought it was something inherent to android.
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 9 guests