2011-04-08 66 views
0

我開發了一款適用於Android的隱藏對象遊戲。我在啓動它之前在各種手機上測試過它,它的工作原理正好適用於所有這些手機。如何在摩托羅拉Cliq上設置視圖背景

我遇到了一個奇怪的問題,似乎只涉及摩托羅拉Cliq。每次嘗試啓動時,它都會關閉應用程序。

在使用絕望的「註釋掉所有的方法」來追蹤錯誤之後,我發現RelativeLayout中的「android:background =」scrollb「是問題,我怎麼解決這個問題?只有在Cliq的發生

這裏是我的代碼:?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="scrollb" android:id="@+id/TableLayout01" android:paddingLeft="5mm" android:paddingRight="5mm" android:gravity = "center_horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fitsSystemWindows="true" android:orientation="vertical"> 

<TextView android:id="@+id/TextView06" android:text="" android:textSize = "10mm" android:gravity = "center_horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"></TextView> 
<TextView android:clickable="true" android:layout_below="@id/TextView06" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView01" android:layout_height="wrap_content" android:text="Play as Guest" android:textSize = "3mm" android:gravity = "center_horizontal" android:layout_width="match_parent"></TextView> 
<TextView android:clickable="true" android:layout_below="@id/TextView01" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView02" android:layout_height="wrap_content" android:text="" android:textSize = "3mm" android:gravity = "center_horizontal" android:layout_width="match_parent" android:visibility="gone"></TextView> 
<TextView android:clickable="true" android:layout_below="@id/TextView02" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView03" android:layout_height="wrap_content" android:text="" android:textSize = "3mm" android:gravity = "center_horizontal" android:layout_width="match_parent" android:visibility="gone"></TextView> 
<TextView android:clickable="true" android:layout_below="@id/TextView03" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView04" android:layout_height="wrap_content" android:text="" android:textSize = "3mm" android:gravity = "center_horizontal" android:layout_width="match_parent" android:visibility="gone"></TextView> 
<TextView android:clickable="true" android:layout_below="@id/TextView04" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView05" android:layout_height="wrap_content" android:text="" android:textSize = "3mm" android:gravity = "center_horizontal" android:layout_width="match_parent" android:visibility="gone"></TextView> 

<EditText android:layout_centerHorizontal="true" android:gravity = "center_horizontal" android:layout_below="@id/TextView05" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="" android:id="@+id/EditText01"></EditText> 

<Button android:layout_centerHorizontal="true" android:layout_below="@id/EditText01" android:layout_width="wrap_content" android:text="Create Player" android:id="@+id/Button01" android:layout_height="wrap_content"></Button> 
<TextView android:layout_centerHorizontal="true" android:gravity = "center_horizontal" android:layout_below="@id/Button01" android:textColor="#8b4513" android:textStyle="italic" android:id="@+id/TextView07" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Welcome to Hidden Treasures,\n your journey awaits"></TextView> 

</RelativeLayout> 

繼承人的堆棧跟蹤:*請注意,我改變了相對佈局爲線性的

04-08 13:39:50.646: ERROR/AndroidRuntime(781): Uncaught handler: thread main exiting due to uncaught exception 
04-08 13:39:50.696: ERROR/AndroidRuntime(781): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.htf/com.htf.main}: android.view.InflateException: Binary XML file line #2: Error inflating class java.lang.reflect.Constructor 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread.access$2000(ActivityThread.java:115) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.os.Looper.loop(Looper.java:123) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread.main(ActivityThread.java:3977) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at dalvik.system.NativeStart.main(Native Method) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class java.lang.reflect.Constructor 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.createView(LayoutInflater.java:512) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.Activity.setContentView(Activity.java:1683) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at com.htf.main.onCreate(main.java:33) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  ... 11 more 
04-08 13:39:50.696: ERROR/AndroidRuntime(781): Caused by: java.lang.reflect.InvocationTargetException 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.widget.LinearLayout.<init>(LinearLayout.java:92) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at java.lang.reflect.Constructor.constructNative(Native Method) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.LayoutInflater.createView(LayoutInflater.java:499) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  ... 21 more 
04-08 13:39:50.696: ERROR/AndroidRuntime(781): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID #0x7f020068 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.content.res.Resources.loadDrawable(Resources.java:1643) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.View.<init>(View.java:1739) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.View.<init>(View.java:1688) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.view.ViewGroup.<init>(ViewGroup.java:271) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  ... 25 more 
04-08 13:39:50.696: ERROR/AndroidRuntime(781): Caused by: java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.content.res.AssetManager.openNonAssetNative(Native Method) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.content.res.AssetManager.openNonAsset(AssetManager.java:417) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  at android.content.res.Resources.loadDrawable(Resources.java:1636) 
04-08 13:39:50.696: ERROR/AndroidRuntime(781):  ... 29 more 
+1

得到堆棧跟蹤? – adamp 2011-04-08 01:13:04

+0

你的佈局文件沒有告訴我們任何東西。按照adamp的建議,如果你可以發佈異常的堆棧跟蹤(如果強制關閉會有異常),那麼它會有所幫助。 – Squonk 2011-04-08 01:29:46

+0

我添加了堆棧跟蹤。我還注意到,emulutor顯示了一個默認圖標,而不是我爲我的遊戲設置的圖標。這會暗示有些資源是非常錯誤的,但這隻發生在摩托羅拉cliq上?對我來說沒有意義。必須愛分散... – Robert 2011-04-08 13:52:52

回答

0

我發現了這個問題。 Android使用hdpi,mdpi,ldpi的三個文件夾。摩托羅拉cliq嘗試通過查看繪圖來訪問資源。只需繪製,不需要hdpi,mdpi,ldpi。當然不存在。