-1

自分のアプリを作りたいのですが、それを起動したいだけです。しかし、何らかの理由でエミュレータで動作させることができません。エラーメッセージがないので、何が悪いのかわかりません:S申し訳ありませんが、プログラミングの初心者で、役立つものが見つかりませんでした。ありがとう !

ここに私のコードがあります:

xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<Button
    android:id="@+id/BBG"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Big Bang Theory" />

<Button
    android:id="@+id/HIMYM"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="How I Met Your Mother" />

</LinearLayout>

アンドロイド マニフェスト:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.watchserie"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".Menu"
        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>

メニュー Java ファイル:

package watchserie.niels;

import com.example.watchserie.R;

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


public class Menu extends Activity {

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu);
}
}
4

1 に答える 1

4

パッケージ名が一致しません。Java ファイルはwatchserie.nielsパッケージに含まれていますが、マニフェストは を使用していますcom.example.watchserie。アクティビティ名の前にドットを使用しているため、パッケージ名が自動的に追加されるように指示します。このため、Activity が であることを Android に伝えていますがcom.example.watchserie.Menu、実際にはwatchserie.niels.Menu

それを修正するには、次のように変更します。

package="com.example.watchserie"

package="watchserie.niels"

そして、Java ファイルから次の行を削除します。

import com.example.watchserie.R;

編集逆に変更することもできますが、Google Play (および他のアプリストアも私が推測する) では、com.example.*名前空間を使用してアプリをアップロードすることはできません。このため、パッケージのないパッケージを選択することをお勧めしますcom.example

于 2013-01-10T19:25:17.700 に答える