• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Hello Android Not working

jplamb

Member
Oct 8, 2009
77
3
UK
I am trying to get the hello android code working and am not having any luck. There are a few things that are different.

When i load Eclipse with a new project the code that is already there looks like this;
package jpl.helloandroid2;

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

public class helloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
when the developers site stays it should look like this (I cahnaged the package name to helloandroid2 as i made a mess of the first one so started again)

package com.example.helloandroid;

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

public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
After i have entered the code which is on the developers site it looks like this

package jpl.helloandroid2;

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

public class helloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
When the site says it should look like

package com.android.helloandroid;

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

public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);

}
}
[/Quote]

I am not sure which version of the code i should be using, When i run the emulator it takes a bit of time to load and then comes up with the homescreen.

when i try to run the app in Eclipse it says. "no compatible Targets were found. Do you wish to add a new Android Virtual Device?"

I click yes it comes up with the options for a new device and if i click no it comes up with the AVD's that i have previously made, when i select one and tell it to start this is when it comes up with the Homescreen.

I am using the lasest version of Eclipse ( i think) i got it from the website

and i have downloaded the Android SDK and AVD Manager and updated them both to have all of the packages.

Any help on how i can get this to work would be great, Thank you for reading

James
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones