Android: android.Blick.InflateException: Binary XML file line #13: Error inflating class <unbekannt> bei SAMSUNG Galaxy S
Ich habe eine seltsame Fehlermeldung, die scheint nur in Samsung Galaxy S mit Android 2.2 (ich habe getestet, die Anwendung in Motorola Milestone 2 Android 2.2 /Xperia X10 Android 1.6 /Nexus One Android 2.2 /Google G1-Android 1.5 und 1.5 emulator und in solchen Geräten tritt der Fehler nicht auf).
Den kompletten stack trace:
ERROR/AndroidRuntime(28111): FATAL EXCEPTION: AsyncTask #2
ERROR/AndroidRuntime(28111): java.lang.RuntimeException: An error occured while executing doInBackground()
ERROR/AndroidRuntime(28111): at android.os.AsyncTask$3.done(AsyncTask.java:200)
ERROR/AndroidRuntime(28111): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
ERROR/AndroidRuntime(28111): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
ERROR/AndroidRuntime(28111): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
ERROR/AndroidRuntime(28111): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
ERROR/AndroidRuntime(28111): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
ERROR/AndroidRuntime(28111): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
ERROR/AndroidRuntime(28111): at java.lang.Thread.run(Thread.java:1096)
ERROR/AndroidRuntime(28111): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
ERROR/AndroidRuntime(28111): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
ERROR/AndroidRuntime(28111): at my.package.MyClass.b(Unknown Source)
ERROR/AndroidRuntime(28111): at my.package.MyClass.a(Unknown Source)
ERROR/AndroidRuntime(28111): at my.package.MyClass.updateUI(Unknown Source)
ERROR/AndroidRuntime(28111): at my.package.MyClass.UpdateUITask.doInBackground(Unknown Source)
ERROR/AndroidRuntime(28111): at android.os.AsyncTask$2.call(AsyncTask.java:185)
ERROR/AndroidRuntime(28111): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
ERROR/AndroidRuntime(28111): ... 4 more
ERROR/AndroidRuntime(28111): Caused by: java.lang.reflect.InvocationTargetException
ERROR/AndroidRuntime(28111): at android.widget.EditText.<init>(EditText.java:101)
ERROR/AndroidRuntime(28111): at java.lang.reflect.Constructor.constructNative(Native Method)
ERROR/AndroidRuntime(28111): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
ERROR/AndroidRuntime(28111): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
ERROR/AndroidRuntime(28111): ... 16 more
ERROR/AndroidRuntime(28111): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
ERROR/AndroidRuntime(28111): at android.os.Handler.<init>(Handler.java:121)
ERROR/AndroidRuntime(28111): at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
ERROR/AndroidRuntime(28111): at android.view.GestureDetector.<init>(GestureDetector.java:370)
ERROR/AndroidRuntime(28111): at android.view.GestureDetector.<init>(GestureDetector.java:347)
ERROR/AndroidRuntime(28111): at android.view.GestureDetector.<init>(GestureDetector.java:331)
ERROR/AndroidRuntime(28111): at android.widget.EditText.<init>(EditText.java:113)
ERROR/AndroidRuntime(28111): ... 20 more
Zunächst, was ist Los? Was ist der größte Fehler? Can't create handler inside thread that has not called Looper.prepare()
oder android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
?
Dies scheint aufzutreten, wenn ich das aufblasen eines View
deren XML (R. layout.field_editable_label_value_numeric) Zeile 13:
<EditText android:id="@+id/editableLabel"
android:layout_gravity="left|center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:textColor="@color/black"
android:textStyle="bold" />
EDIT: ich habe vergessen zu sagen, dass ich mit Proguard, weiß nicht, ob das irgendwie Einfluss hat auf dieses Problem (ich denke nicht).
Habe ich auch noch den code, wo ich denke, das problem ist passiert:
MyClass.a:
final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ArrayList<View> views = MyClass.b(inflater);
runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.ItemLinearLayout);
//clear UI
mainLayout.removeAllViews();
//re-set all views
for (View view : views) {
mainLayout.addView(view);
}
}
}
MyClass.b:
final ArrayList<View> viewsToAdd = new ArrayList<View>();
View view = inflater.inflate(R.layout.field_editable_label_value_numeric, null, true);
viewsToAdd.add(view);
return views;
dymmeh ich gerade editierte und ergänzte code
InformationsquelleAutor pandre | 2011-07-13
Du musst angemeldet sein, um einen Kommentar abzugeben.
Danke für die Antworten, aber die beste Erklärung, die ich bekam war das hier: Aufblasen, ein Blick in einen hintergrund-thread
Im Grunde, so scheint es, dass Samsung Galaxy S hat einen
EditText
Umsetzung dessen die inflation nur in den UI-Thread.Hoffe, dies hilft jemand, der läuft in der gleichen Art von problem.
InformationsquelleAutor pandre
Nicht aktualisieren Sie Ihre Benutzeroberfläche aus einem background thread-UI thread nur.
Den stack-trace sieht aus wie die inflation geschieht in der
doInBackground
Methode eines AsyncTask. Das ist wohl diese Zeile:Wenn das der Fall ist, dann sollten Sie es aus dem hintergrund-thread. Wenn der code, den Sie geschrieben ist in der Tat die
doInBackground
, möglicherweise möchten Sie auch zu erwägen, in IhrerunOnUiThread
block inonPostExecute
.InformationsquelleAutor Mike
Wahrscheinlich ähnliches problem wie dort: EditText seltsam Absturz auf LG Optimus w/Swype (funktioniert auf dem emulator und Droiden)
Scheint es, dass Berufung Einlegen.prepare() im UI-thread wird dieses Problem beheben Ausnahme.
Mehr info dort: http://developer.android.com/reference/android/os/Looper.html
InformationsquelleAutor pawelzieba