1

I know that the heading of this thread sound silly, but I can not repair my code.

package HelloAndroid;

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

public class HelloAndroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView view = new TextView(this);
    view.setText("LOL View Working!");
    setContentView(view);
}
}

My problem is that I'm getting error in emulator: process not reponding or something similair. Why?! This application is so small so why it does not works?! Please help me.

EDIT:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="HelloAndroid.Main"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".HelloAndroidActivity"
            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>
neatnick
  • 1,489
  • 1
  • 18
  • 29
user35443
  • 6,309
  • 12
  • 52
  • 75

4 Answers4

3

in AndroidManifest.xml, replace:

package="HelloAndroid.Main"

with:

package="HelloAndroid"

or move your java source file, into HelloAndroid.Main package by replacing the first line with:

package HelloAndroid.Main;
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
1

I think you get that error because package is not the same

in manifest u have: package="HelloAndroid.Main" while in class is just package HelloAndroid;

hop

Ewoks
  • 12,285
  • 8
  • 58
  • 67
  • 1
    ah u r welcome.. we r here to help each other and make community better place for learning, not to compete how is faster ;) Cheers **Welcome to android wonderland ;)** – Ewoks Feb 27 '12 at 10:42
  • 2
    ah u got me wrong.. :S I said I am not here to compete, but to learn and help others to learn.. ;) Eng.Fouad was first and he deserved Accepted.. – Ewoks Feb 27 '12 at 10:57
1

The

package 'AndroidManifest.xml' must have a minimum of 2 segments.

So your package name should also have two segments like this

com.HelloAndroid

droid kid
  • 7,569
  • 2
  • 32
  • 37
1

try this

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.Id);
    TextView view = new TextView(this);
    view.setText("LOL View Working!");
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98