2012-08-17 146 views
0

我已經創建了一個目標api爲4.0.3(15)的應用程序,然而我在min api 2.3.3(10)的清單中設置,當我在我的4.0設備上運行應用程序時, ,當我運行它在我的2.3設備上它不會加載只是在啓動時關閉力...android應用程序兼容性

我知道android有構建之間的碎片問題,我想知道是否有一種簡單的方法,應用程序在這兩個系統上工作,或者我將不得不編碼2.3版本。我是一個新手編碼器,所以請對我溫柔。

08-17 18:57:15.722: D/AndroidRuntime(4535): Shutting down VM 
08-17 18:57:15.722: W/dalvikvm(4535): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 
08-17 18:57:15.722: E/AndroidRuntime(4535): FATAL EXCEPTION: main 
08-17 18:57:15.722: E/AndroidRuntime(4535): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.reading.festival/com.reading.festival.ReadingFestival2012Activity}: java.lang.ClassNotFoundException: com.reading.festival.ReadingFestival2012Activity in loader dalvik.system.PathClassLoader[/data/app/com.reading.festival-1.apk] 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.os.Looper.loop(Looper.java:150) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread.main(ActivityThread.java:4385) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at java.lang.reflect.Method.invoke(Method.java:507) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at dalvik.system.NativeStart.main(Native Method) 
08-17 18:57:15.722: E/AndroidRuntime(4535): Caused by: java.lang.ClassNotFoundException: com.reading.festival.ReadingFestival2012Activity in loader dalvik.system.PathClassLoader[/data/app/com.reading.festival-1.apk] 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.Instrumentation.newActivity(Instrumentation.java:1040) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777) 
08-17 18:57:15.722: E/AndroidRuntime(4535):  ... 11 more 

主要活動

package com.reading.festival; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.Window; 
import android.view.WindowManager; 
import android.widget.Button; 

public class ReadingFestivalGuide2012Activity extends Activity { 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //makes full screen and takes away title bar 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    // 

    setContentView(R.layout.main); 

    Button sitemap = (Button) findViewById(R.id.sitemap); 
    sitemap.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      Intent myIntent = new Intent(view.getContext(), sitemap.class); 
      startActivityForResult(myIntent, 0); 
     } 
    }); 

    Button lineup = (Button) findViewById(R.id.lineup); 
    lineup.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      Intent myIntent = new Intent(view.getContext(), lineup.class); 
      startActivityForResult(myIntent, 0); 
       } 
      }); 
     } 
    } 
+1

請編輯您的帖子LogCat日誌由force-close提供。它還有助於查看來自主類的代碼,特別是'onCreate'。 – Eric 2012-08-17 17:44:12

回答

1

您需要檢查的logcat的確切錯誤。 您的錯誤可能是您正在使用對您的2.3設備無法使用的「較新」代碼段的調用。 Logcat是必須的(用於跟蹤異常並找出應用程序出了什麼問題),但通過將目標SDK更改爲10並檢查編譯錯誤,可輕鬆檢查我提到的問題。

0

好通過我的代碼,看完之後我已成功地制定出我使用的東西中的XML叫,我已經找到了去除現在這個心不是支持API低於14,現在可