2013-05-06 169 views
-4

我有這個源代碼,我試圖使它工作,我把它從網上教程。 它的問題是,我得到一個錯誤: 「不幸的是MainScreen已停止」;現在不幸的是,應用程序已停止在Android應用程序的問題

,我看了網上找到一個可行的解決方案,發現它可能是在AndroidManifest.xml中,我改變了AP的名稱com.example.androidhive又一次沒有機會..

這裏驗證碼:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.androidhive" 
    android:versionCode="1" 
    android:versionName="1.0" > 

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

    <application 
     android:configChanges="keyboardHidden|orientation" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 


     <activity 
      android:name=".MainScreenActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

     <!-- All Product Activity --> 
     <activity 
      android:name=".AllProductsActivity" 
      android:label="All Products" > 
     </activity> 

     <!-- Add Product Activity --> 
     <activity 
      android:name=".NewProductActivity" 
      android:label="Add New Product" > 
     </activity> 

     <!-- Edit Product Activity --> 
     <activity 
      android:name=".EditProductActivity" 
      android:label="Edit Product" > 
     </activity> 
    </application> 

    <!-- Internet Permissions --> 
    <uses-permission android:name="android.permission.INTERNET" /> 

</manifest> 

謝謝..

登錄

05-06 08:29:03.940: E/AndroidRuntime(757): FATAL EXCEPTION: AsyncTask #1 
05-06 08:29:03.940: E/AndroidRuntime(757): java.lang.RuntimeException: An error occured while executing doInBackground() 
05-06 08:29:03.940: E/AndroidRuntime(757): at android.os.AsyncTask$3.done(AsyncTask.java:299) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.lang.Thread.run(Thread.java:856) 
05-06 08:29:03.940: E/AndroidRuntime(757): Caused by: java.lang.NullPointerException 
05-06 08:29:03.940: E/AndroidRuntime(757): at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:130) 
05-06 08:29:03.940: E/AndroidRuntime(757): at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:1) 
05-06 08:29:03.940: E/AndroidRuntime(757): at android.os.AsyncTask$2.call(AsyncTask.java:287) 
05-06 08:29:03.940: E/AndroidRuntime(757): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 
05-06 08:29:03.940: E/AndroidRuntime(757): ... 4 more 
+0

您需要了解如何使用logcat ... – Selvin 2013-05-06 08:41:10

+0

請發佈您的日誌 – 2013-05-06 08:41:23

+0

我們需要LogCat輸出。謝謝。 – sebastian 2013-05-06 08:42:29

回答

0

你的日誌貓顯示NullPointerException

05-06 08:29:03.940: E/AndroidRuntime(757): Caused by: java.lang.NullPointerException 

,似乎無在線: - 130 AllProductsAct.java的的AsyncTask的doInBackground方法。檢查那一行應該有一個尚未分配的變量。

05-06 08:29:03.940: E/AndroidRuntime(757): at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:130) 

也發佈您的代碼。

相關問題