Confusion about "Sorry! The application ____ (process ____) has stopped unexpectedly..." message

by illiniwatcher » Mon, 03 Nov 2008 13:38:58 GMT


Sponsored Links
 i, folks:

I am really confused about Android at this point. I'm writing a very
simple application called "Counter" (a starting point) that uses a
drawabl PNG image and no matter what I do, when I run it in the
emulator, I get this annoying message:

"Sorry! The application Counter (process mine.counter) has
stopped unexpectedly. Please try again. [Force close buttton]"

All I want my application to do is to display a Drawable called
"n0.png" which I have defined to my "rsc\drawable" folder.

I've looked at other sample applications, including the ones in the
SDK and tried emulating the coding, without success. I'm very
confused about how the Java, XML, and other files interact. I just
don't see why the program is freezing when I've practically followed
the structure of other applications to the letter.

Below, I've replicated the code. Thanks for any help you can provide.

Charles

***************

FILE STRUCTURE

Counter
res
drawable
n0.png
layout
bkcounter.xml
main.xml
values
colors.xml
strings.xml
src
mine
counter
Counter.java
CounterView.java
R.java


In BKCOUNTER.XML:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Demonstrates using a relative layout to create a form -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10px"
android:background="@color/blueback">

<!-- My connection to the view; THIS TIES IN ANDROID CLASSES (!) -->
<!-- "id" value will show up when using auto-complete -->

<mine.counter.CounterView
android:id="@+id/cview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<ImageView android:id="@+id/firstdigit"
android:layout_height="fill_parent"
android:layout_width="fill_parent"></ImageView>

</FrameLayout>


In MAIN.XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>


In COLORS.XML:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
<color name="blueback">#0071BC</color>
</resources>


In STRINGS.XML:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Counter</string>
<string name="app_name">Counter</string>
</resources>


In COUNTER.JAVA:

package mine.counter;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bun



Confusion about "Sorry! The application ____ (process ____) has stopped unexpectedly..." message

by songs » Mon, 03 Nov 2008 15:08:46 GMT


 i,

The first thing you need to do is to look at the logs. Open up a
shell to the sdk and fire up: adb logcat. This will show you the
actual stacktrace that's coming up and you should be able to figure
out the issue from there.

Regards,
Steve

On Nov 2, 9:32pm, illiniwatcher <[EMAIL PROTECTED]> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. How to access the build-in wallpaper gallery?

I try to read the picture in the build-in wallpaper gallery, but can't
find where there are. Could somebody tell me how to do this? thanks.

-- 

2. dynamically textline in SimpleAdapter

Hi!

I'm junior in andoid programming.
I would like to make a application in which there is an edit text and
if you write in a number and press a button, it would dinamically show
as many textview lines as the given number. The problem is that I
cannot number the textview lines. For example, if I write ten in the
edit text and press the button than number 9 will appear at the
beginning of all the lines. Could you help me with this problem?

Java:
package com.novoda;

import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter;

public class DynamicListItems extends ListActivity {

     private static final String ITEM_KEY = "key";
     ArrayList<HashMap<String, String>> list = new
ArrayList<HashMap<String, String>>();
     private EditText newValue;
     private SimpleAdapter notes;
     private int szam = 0;
     private int[] tomb = new int[10];
     private String[] key = new String[10];

     @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.dynamic_list);

          newValue = (EditText) findViewById(R.id.new_value_field);

          notes = new SimpleAdapter(
                    this,
                    list,
                    R.layout.row,
                    new String[] { ITEM_KEY },
                    new int[] { R.id.list_value });

          Button ib = (Button) findViewById(R.id.button);

          ib.setOnClickListener(new View.OnClickListener() {
               public void onClick(View view) {
                    try {
                         szam =
Integer.valueOf(newValue.getText().toString()).intValue();
                         HashMap<String, String> item = new
HashMap<String, String>();
                         list.clear();
                         for(int i = 0;i < szam;i++){
                              item.put(ITEM_KEY, i+". line");
                              list.add(item);
                         }
                         setListAdapter(notes);

                    } catch (NullPointerException e) {
                         Log.i("[Dinamikus elemek]", "Megprbltl
hozzadni egy null rtket.");
                    }
               }
          });
     }
}


dynamic_list.xml

XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
     android:orientation="vertical" android:layout_width="fill_parent"
     android:layout_height="fill_parent">

     <TableLayout android:id="@+id/TableLayout01"
          android:layout_height="wrap_content"
android:orientation="vertical"
          android:layout_width="fill_parent">
          <EditText android:id="@+id/new_value_field"
               android:textColor="#020905"
               android:layout_marginTop="6px"
android:layout_marginBottom="8px"
               android:layout_width="fill_parent"
android:layout_height="fill_parent"
               android:layout_marginLeft="2px"
android:layout_marginRight="2px" />
          <Button android:text="Press" android:id="@+id/button"
               android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
     </TableLayout>
     <ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
          android:layout_height="0px" android:layout_weight="1"
          android:cacheColorHint="#00000000">
     </ListView>


</LinearLayout>


row.xml

XML:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
     android:layout_width="fill_parent"
android:layout_height="wrap_content"
     android:background="#00000000">

     <TextView android:id="@+id/list_value"
android:layout_width="fill_parent"
          android:layout_height="wrap_content" />
</LinearLayout>

-- 

3. Binding resources programmatically

4. dinamically textline in SimpleAdapter

5. Direct audio between PC and droid device

6. Question about XML layout attributes and CustomView class

7. create TextView