Android HelloWorld response
-
13-11-2019 - |
Question
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>
Solution
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;
OTHER TIPS
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
The
package 'AndroidManifest.xml' must have a minimum of 2 segments.
So your package name should also have two segments like this
com.HelloAndroid
try this
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.Id);
TextView view = new TextView(this);
view.setText("LOL View Working!");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow