0

I am trying to set up an eclipse environment on windows 64. I think I have done everything in the tutorial (developer.android.com) but when I select the project in eclipse to run i get the emulator to pop up but it doesn't show hello world.

I tried android version 2.1 and the emulator poped up and just eventual went to a black screen after showing ANDROID...

I tried as 4.0.3 and after the emulator popped up I just saw a plane jane android phone interface it wouldn't run my app. The code is below. Does anyone know what i am missing?

Eclipse displays the following when I run the emulator

[2012-02-19 11:58:40 - trst] ------------------------------
[2012-02-19 11:58:40 - trst] Android Launch!
[2012-02-19 11:58:40 - trst] adb is running normally.
[2012-02-19 11:58:40 - trst] Performing com.example.helloandroid.TrstActivity activity launch
[2012-02-19 11:58:40 - trst] Automatic Target Mode: launching new emulator with compatible AVD 'interface'
[2012-02-19 11:58:40 - trst] Launching a new emulator with Virtual Device 'interface'
[2012-02-19 11:58:55 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error
[2012-02-19 11:58:55 - trst] New emulator found: emulator-5554
[2012-02-19 11:58:55 - trst] Waiting for HOME ('android.process.acore') to be launched...

code:

package com.example.helloandroid;

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

public class TrstActivity 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);
    }
}
Yury
  • 20,618
  • 7
  • 58
  • 86

5 Answers5

1

I just would like to add that I saw the Android screen and it did nothing for at least 2 minutes and I thought my application had crashed also. But actually I think this was just the virtual device booting up.

After two or three minutes, the Android log was replaced by a login/splash screen - once I clicked on unlock ... I finally saw my "hello world" message .... what relief !!!!

hughabbott
  • 11
  • 1
0

I restarted Eclipse,opened the main activity.java file in src folder,changed the string to hello android and ran the code. It pops out an error saying: no such file/string found. Then I renamed it back to hello_world and ran and it worked.

tostao
  • 2,803
  • 4
  • 38
  • 61
Venkatesh
  • 11
  • 1
0

Apparent solution may be just try clicking on back button of emulator. (as I couldn't find any other mistake in your code)
Also please paste Logcat so that we can identify exact cause.

Community
  • 1
  • 1
Ajinkya
  • 22,324
  • 33
  • 110
  • 161
0

Does console give you anything in the logs about why it doesn't run? I've never used setContentView(int) like that. I've always used it with a layout like R.layout.hello (or whatever you have here) and then you can reference the TextView like this

TextView mTextView = findViewById(R.id.myTextView);
mTextView.setText("Hello, Android!");

Hope this helps.

Daniel Lockard
  • 615
  • 3
  • 11
0

You may have the same issue I did when I first started, the emulator takes quite a while to start up, give it 5-10 minutes and if it still fails, you will need to show us the logcat.

jersam515
  • 657
  • 6
  • 22