Re: [android-developers] android resources error after upgrade to honeycomb and adt v10

2011-02-24 Thread J Handal

 A reference to tv has to be set outside onCreate()


TextView tv has to be a member variable.

Inside the onCreate() tv is short lived.




02-24 16:09:25.374: ERROR/AndroidRuntime(537): Caused by:
 java.lang.NullPointerException
02-24 16:09:25.374: ERROR/AndroidRuntime(537): at
 it.prova.EmptyActivity.onCreate(EmptyActivity.java:22)
02-24 16:09:25.374: ERROR/AndroidRuntime(537): at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
 1047)
02-24 16:09:25.374: ERROR/AndroidRuntime(537): at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2627)
02-24 16:09:25.374: ERROR/AndroidRuntime(537): ... 11 more

 I'm using sdk r11 and adt v10.

 I think there is a problem with resources.

 Any idea?

 Thanks.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] android resources error after upgrade to honeycomb and adt v10

2011-02-24 Thread Mark Murphy
If you use Eclipse, do Project | Clean from the main menu. If you use
Ant, run ant clean install. See if one of these clears up your
problem.

On Thu, Feb 24, 2011 at 10:28 AM, Premier a.grum...@gmail.com wrote:
 Hello,
 i've created a new android project target 8, with default activity

 I've assigned an id to textview with text Hello world.

    ?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:id=@+id/tvProva
        android:layout_width=fill_parent
        android:layout_height=wrap_content
        android:text=@string/hello
        /
    /LinearLayout

 This is the unique activity

    package it.prova;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;


    public class EmptyActivity extends Activity
    {

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

        TextView tv = (TextView) findViewById(R.id.tvProva);
        tv.setText(Prova );
    }
    }

 And this is logcat


    02-24 16:09:25.374: ERROR/AndroidRuntime(537): Caused by:
 java.lang.NullPointerException
    02-24 16:09:25.374: ERROR/AndroidRuntime(537):     at
 it.prova.EmptyActivity.onCreate(EmptyActivity.java:22)
    02-24 16:09:25.374: ERROR/AndroidRuntime(537):     at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
 1047)
    02-24 16:09:25.374: ERROR/AndroidRuntime(537):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2627)
    02-24 16:09:25.374: ERROR/AndroidRuntime(537):     ... 11 more

 I'm using sdk r11 and adt v10.

 I think there is a problem with resources.

 Any idea?

 Thanks.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.4 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en