¡Omitió 49 cuadros! La aplicación puede estar haciendo demasiado trabajo en su hilo principal

Estoy inflando vistas (no fragmentos) en mi implementación viewpager. Mi clase principal extiende Actividad. Me enfrento a este error cuando intento deslizar la pantalla de mi aplicación o

at com.example.app.CustomPagerAdapter.instantiateItem(CustomPagerAdapter.java:47)

y

 01-04 16:44:35.5278614-8614/com.parsizabanan.app W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4195ee48) 01-04 16:44:35.5278614-8614/com.parsizabanan.app E/AndroidRuntime﹕ FatAL EXCEPTION: main Process: com.parsizabanan.app, PID: 8614 android.view.InflateException: Binary XML file line #6: Error inflating class <unknown> at android.view.LayoutInflater.createView(LayoutInflater.java:620) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInfl ater.java:56) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.parsizabanan.app.CustomPagerAdapter.instantiateItem(CustomPagerAdapter.java:47) at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110) at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:837) at android.support.v4.view.ViewPager.populate(ViewPager.java:1021) at android.support.v4.view.ViewPager.populate(ViewPager.java:919) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441) at android.view.View.measure(View.java:16574) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1406) at android.widget.LinearLayout.measureVertical(LinearLayout.java:697) at android.widget.LinearLayout.onMeasure(LinearLayout.java:590) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2421) at android.view.View.measure(View.java:16574) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1955) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1151) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1333) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1038) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5890) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5118) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInfl ater.java:56) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.parsizabanan.app.CustomPagerAdapter.instantiateItem(CustomPagerAdapter.java:47) at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110) at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:837) at android.support.v4.view.ViewPager.populate(ViewPager.java:1021) at android.support.v4.view.ViewPager.populate(ViewPager.java:919) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441) at android.view.View.measure(View.java:16574) at android.widget.RelativeLayout.measureChildHorizontal(Rel ativeLayout.java:719) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1406) at android.widget.LinearLayout.measureVertical(LinearLayout.java:697) at android.widget.LinearLayout.onMeasure(LinearLayout.java:590) at android.view.View.measure(View.java:16574) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2421) at android.view.View.measure(View.java:16574) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1955) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1151) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1333) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1038) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5890) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5118) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422) at android.graphics.drawable.Drawable.cre ateFromResourceStream(Drawable.java:840) at android.content.res.Resources.loadDrawable(Resources.java:2150) 

CustomPagerAdapter:

 public class CustomPagerAdapter extends PagerAdapter { public Object instantiateItem(View collection, int position) { LayoutInflaterinflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLatER_SERVICE); int resId = 0; switch (position) { case 0: { resId = R.layout.lab; break; } case 1: { resId = R.layout.lab; break; } case 2: { resId = R.layout.etela; break; } case 3: { resId = R.layout.ticket; break; } case 4: { resId = R.layout.product; break; } case 5: { resId = R.layout.about; break; } } View view = inflater.inflate(resId, null); ((ViewPager) collection).addView(view, 0); return view; } @Override public void destroyItem(View arg0, int arg1, Object arg2) { ((ViewPager) arg0).removeView((View) arg2); } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == ((View) arg1); } @Override public Parcelable saveSt ate() { return null; } @Override public int getCount() { return 6; } 

Mi actividad:

 public class MyActivity extends Activity { ViewPager myPager = null; ImageButton contact = null; ImageButton about = null; ImageButton lab = null; ImageButton product = null; ImageButton ticket = null; ImageButton etela = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); CustomPagerAdapter adapter = new CustomPagerAdapter(); myPager = (ViewPager) findViewById(R.id.customviewpager); myPager.setAdapter(adapter); myPager.setCurrentItem(5); myPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrolled(int i, flo at v, int i2) { } public void onPageSelected(int i) { } public void onPageScrollStateChanged(int i) { Thread t1 = new Thread(new Runnable() { @Override public void run() { switch (myPager.getCurrentItem()) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; } } }); t1.start(); } }); } 

Y es el diseño de laboratorio:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/lab1"/> </LinearLayout> 

One Solution collect form web for “¡Omitió 49 cuadros! La aplicación puede estar haciendo demasiado trabajo en su hilo principal”

El uso de imágenes grandes podría causar este error. Es muy recomendable reducir los tamaños de las imágenes y luego cargarlas en ImageViews.

También hay otra manera de solicitar android para darle a tu aplicación más memoria añadiendo lo siguiente al manifiesto. Pero esto no es recomendable. Para más información, mira aquí y aquí .

 <application ... android:largeHeap="true" ... > ... </application> 
  • Obtención de un token de acceso malformado "t ype": "OAuthException", "code": 190
  • Mockito con Robolectric: "ClassCastException se produjo al crear el proxy"
  • 'Debe sustituir un método de superclase' Errores después de importar un proyecto en Eclipse
  • Cómo cambiar pantallas en Scene2D libGDX
  • Nombre de la unidad organizativa
  • No se puede establecer el valor DSCP en la aplicación android
  • {Entrada de Facebook} java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
  • DoInBackground () error en facebook api en android studio
  • Class Dimension para java en android
  • String.equals () con varias condiciones (y una acción en el resultado)
  • ¿Hay algún sitio web que muestre todos los componentes y widgets de interfaz de usuario disponibles con código fuente?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.