3

I'm new to android and learning its programming. I created the very first app but got stuck at one point. I created AVD on Eclipse Helios Service Release 2 and ran the application but got below error:

[2012-10-21 13:56:12 - FirstApp] ------------------------------
[2012-10-21 13:56:12 - FirstApp] Android Launch!
[2012-10-21 13:56:12 - FirstApp] adb is running normally.
[2012-10-21 13:56:12 - FirstApp] Performing com.example.firstapp.MainActivity activity launch
[2012-10-21 13:56:13 - FirstApp] Automatic Target Mode: launching new emulator with compatible AVD 'Virtual'
[2012-10-21 13:56:13 - FirstApp] Launching a new emulator with Virtual Device 'Virtual'
[2012-10-21 13:57:44 - Emulator] Failed to create Context 0x3005
[2012-10-21 13:57:44 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2012-10-21 13:57:50 - FirstApp] New emulator found: emulator-5554
[2012-10-21 13:57:50 - FirstApp] Waiting for HOME ('android.process.acore') to be launched...

Below is my code:

AndroidManifest.xml-

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

MainActivity.java-

 package com.example.firstapp;  

 import android.os.Bundle;  
 import android.view.Menu;  
 import android.app.*;  

 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.*;  
 import java.util.*;  
 public class MainActivity extends Activity implements OnClickListener {  

Button btn;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        

    btn=new Button(this);
    btn.setOnClickListener(this);
    updateTime();
    setContentView(btn);
    }
    public void onClick(View view) {
    updateTime();
    }
    private void updateTime() {
    btn.setText(new Date().toString());
    }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

public void onStart(Bundle savedInstanceState)
{
    super.onRestoreInstanceState(savedInstanceState);
}
}

I'm using Android Version 4.1 and have installed Android SDk properly.
I searched internet for solution and tried many options like deleting existing AVD and creating a new one, restarting Eclipse, also set the GPU Emulation property to yes but none of them worked.

Please guide me as in where am I going wrong.

4

0 回答 0