2013-01-10 51 views
-1

我想製作自己的應用程序,而我只是非常想啓動它。但由於某種原因,我不能讓它在我的模擬器上工作。我沒有錯誤消息,所以我不知道什麼是錯的:S對不起,我在編程中一個novic,我找不到任何幫助我的東西。謝謝 !Android應用程序無法啓動,可能是Android清單

這裏是我的代碼:

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> 

Android清單:

<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); 
} 
} 
+0

你是什麼意思「我不能讓它工作。」?它在做什麼或不做什麼? – BlackHatSamurai

+0

檢查佈局xml文件的名稱,以及您傳遞給setContentView的id的名稱 – DGomez

回答

4

你的包名不匹配。您的Java文件位於watchserie.niels包中,而您的清單使用com.example.watchserie。由於您在活動名稱之前使用點,它會指示將名稱自動添加到該名稱中。由於這個原因,你告訴的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的包裝。

+1

謝謝它工作! –

+1

@ user1330133我很高興它!您可以通過單擊左側投票計數下的複選標記將此答案標記爲正確,以便將此問題標記爲已解決並且不會保留在未答覆選項卡中。 –

+1

好吧我會盡快做到這一點:D再次感謝 –

相關問題