title: Android: android.view.InflateException: Binary XML file line #13: Error inflating class <unknown> in SAMSUNG Galaxy S
body: <p>I am having a strange error that seems to occur only in Samsung Galaxy S with Android 2.2 (I've tested the application in Motorola Milestone 2 Android 2.2 / Xperia X10 Android 1.6 / Nexus One Android 2.2 / Google G1 Android 1.5 and 1.5 emulator and in such devices the error does not occur).  </p>
  
  <p>The complete stack trace is:  </p>
  
  <pre><code>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 &lt;unknown&gt;
  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.&lt;init&gt;(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.&lt;init&gt;(Handler.java:121)
  ERROR/AndroidRuntime(28111):     at android.view.GestureDetector$GestureHandler.&lt;init&gt;(GestureDetector.java:250)
  ERROR/AndroidRuntime(28111):     at android.view.GestureDetector.&lt;init&gt;(GestureDetector.java:370)
  ERROR/AndroidRuntime(28111):     at android.view.GestureDetector.&lt;init&gt;(GestureDetector.java:347)
  ERROR/AndroidRuntime(28111):     at android.view.GestureDetector.&lt;init&gt;(GestureDetector.java:331)
  ERROR/AndroidRuntime(28111):     at android.widget.EditText.&lt;init&gt;(EditText.java:113)
  ERROR/AndroidRuntime(28111):     ... 20 more
  </code></pre>
  
  <p>First of all, what is going on?  What is the main error? <code>Can't create handler inside thread that has not called Looper.prepare()</code> or <code>android.view.InflateException: Binary XML file line #13: Error inflating class &lt;unknown&gt;</code> ?  </p>
  
  <p>This seems to occur when I am inflating a <code>View</code> whose XML (R.layout.field_editable_label_value_numeric) line 13 is:  </p>
  
  <pre><code>        &lt;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" /&gt;
  </code></pre>
  
  <p>EDIT: I forgot to tell that I am using Proguard, don't know if that somehow has influence on this issue (I don't think so).  </p>
  
  <p>I also added the code where I think the problem is happening:  </p>
  
  <p>MyClass.a:  </p>
  
  <pre><code>final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  final ArrayList&lt;View&gt; 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);
              }
          }
  }
  </code></pre>
  
  <p>MyClass.b:  </p>
  
  <pre><code>final ArrayList&lt;View&gt; viewsToAdd = new ArrayList&lt;View&gt;();
  
  View view = inflater.inflate(R.layout.field_editable_label_value_numeric, null, true);
  viewsToAdd.add(view);
  
  return views;
  </code></pre>