2012-04-11 26 views
0

私はEclipseのアンドロイドプラグインで全く新しいものではありませんが、私は最初からプロジェクトを書く際に新しいです。だから私はAndroid開発者のウェブサイトに行き、「Hello World」のチュートリアルに従いました。Androidプログラム起動失敗

私のプログラムを実行すると、エミュレータは残念なことに、 という画面を表示します。 私のコードは次のとおりです。

HelloAndroid.Java

package daniel.android.projects; 

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); 
      Object o = null; 
      o.toString(); 
      setContentView(R.layout.main); 
     } 
    } 

Main.xml

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/textview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="@string/hello"/> 

のstrings.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="hello">Hello, Android! I am a string resource!</string> 
    <string name="app_name">Hello, Android</string> 
</resources> 

たManifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="daniel.android.projects" 
    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=".AndroidTesterActivity" 
      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> 

答えて

1

あなたがonullを割り当て、それにtoString()を呼び出し、nullポインタ例外があります。

Object o = null; 
o.toString(); 

それはとにかく、あなたのアプリケーションでは何も提供しないように、それはすべきではないようです。

また、あなたのコードを見て、あなたがHelloAndroidクラスを作成しますが、themanifestにあなたはそれが私はそれがエラーを投げる見ることができるようにヌルポインタが意図的だった

android:name=".HelloAndroid" 
+0

でなければなりません

android:name=".AndroidTesterActivity" 

を宣言 – kreeSeeker

+0

エラーがスローされると、アプリケーションはロードされません。 – MByD

+0

hh。チュートリアルはそれをそこに置くと言いました。 – kreeSeeker

関連する問題