I am getting kind of report from user in error report on Google play. I never get this error in my phone galaxy s2 i9100 and other Android phones which I have.
java.lang.RuntimeException: Unable to start activity ComponentInfo{AnantApps.Moodlytics/anantapps.moodlytics.ui.WhatsNewSlideshow}: android.view.InflateException: Binary XML file line #39: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at anantapps.moodlytics.ui.WhatsNewSlideshow.setupSlideShow(WhatsNewSlideshow.java:106)
at anantapps.moodlytics.ui.WhatsNewSlideshow.initViews(WhatsNewSlideshow.java:87)
at anantapps.moodlytics.ui.WhatsNewSlideshow.onCreate(WhatsNewSlideshow.java:55)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 27 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:775)
at android.content.res.Resources.loadDrawable(Resources.java:1968)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:119)
at android.widget.ImageView.<init>(ImageView.java:109)
... 30 more
Some times user report this kind of error also but I failed to reproduce it.
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:775)
at android.content.res.Resources.loadDrawable(Resources.java:1968)
at android.content.res.Resources.getDrawable(Resources.java:677)
at android.widget.ImageView.resolveUri(ImageView.java:542)
at android.widget.ImageView.setImageResource(ImageView.java:315)
at anantapps.moodlytics.ui.WhatsNewSlideshow.setupSlideShow(WhatsNewSlideshow.java:118)
at anantapps.moodlytics.ui.WhatsNewSlideshow.initViews(WhatsNewSlideshow.java:87)
at anantapps.moodlytics.ui.WhatsNewSlideshow.onCreate(WhatsNewSlideshow.java:55)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
in Activity, My function is like this....
private void setupSlideShow(ArrayList<String> titles, ArrayList<String> desc) {
realViewSwitcher = (HorizontalPager) findViewById(R.id.horizontalPager);
realViewSwitcher.removeAllViews();
LayoutInflater inflater = getLayoutInflater();
for (int i = 0; i < titles.size(); i++) {
View v = inflater.inflate(R.layout.whats_new_slide_show_item, null);
TextView titleTV = (TextView) v
.findViewById(R.id.whats_new_item_title);
titleTV.setTypeface(CommonFunctions.getBold(getContext()));
titleTV.setText(titles.get(i));
TextView descTV = (TextView) v
.findViewById(R.id.whats_new_item_desc);
descTV.setTypeface(CommonFunctions.getNormal(getContext()));
descTV.setText(desc.get(i));
ImageView img = (ImageView) v.findViewById(R.id.img_whats_slide);
img.setImageResource(imgResources.get(i));
realViewSwitcher.addView(v);
}
realViewSwitcher.setOnScreenSwitchListener(onScreenSwitchListener);
}
whats_new_slide_show_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingLeft="10dp" >
<TextView
android:id="@+id/whats_new_item_title"
style="@style/whats_new_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large Text" />
</LinearLayout>
<ImageView
android:id="@+id/img_whats_slide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bug_fixes" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingTop="3dp" >
<TextView
android:id="@+id/whats_new_item_desc"
style="@style/whats_new_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
whats_new_slide_show.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/whats_new_slides_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bar_bg"
android:orientation="horizontal" >
<TextView
android:id="@+id/whats_new_header"
style="@style/TopBarTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/whats_new_title" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@drawable/seperator_whats_new" >
</LinearLayout>
<Button
android:id="@+id/btn_next_slide"
style="@style/Whats_new_btn"
android:layout_width="65dp"
android:layout_height="match_parent"
android:background="@drawable/whats_new_next_btn"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/btn_next" />
</LinearLayout>
<LinearLayout
android:id="@+id/whats_new_slides_container"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/tra_white_ninety" >
<anantapps.moodlytics.view.HorizontalPager
android:id="@+id/horizontalPager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</anantapps.moodlytics.view.HorizontalPager>
</LinearLayout>
It looks like you are trying to pre-load all your images for your slideshow. If you redesign your app to only load images when they are viewed, it will have much less peak memory usage which will help you avoid out-of-memory issues.