What is Native crash at /system/lib/libc.so? - android

I am getting crash while scrolling down and up a listview from my app but the error is not quite understandable. I am attaching the bug report screenshot from Google Developer Console.
Please go through it.
Adapter getView Code:
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.adapter_item_list,
parent, false);
holder.labelName = (TextView) convertView
.findViewById(R.id.item_label);
holder.labelInfo = (TextView) convertView
.findViewById(R.id.item_info);
holder.mImgArrow = (ImageView) convertView
.findViewById(R.id.iv_arrow);
holder.mImgIcon = (RoundCornerImage) convertView
.findViewById(R.id.grid_item_image);
holder.relative_cell_view = (RelativeLayout) convertView
.findViewById(R.id.relative_cell_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
appSharedPrefrence = AppSharedPrefrence.getsharedprefInstance(context);
final FileBean dataBean = dataList.get(position);
holder.labelName.setText(position+" : "+dataBean.getName());
holder.labelInfo.setText(replace_comma(dataBean.getinfo()));
try{
ImageLoader.getImageLoader(context).DisplayImage(dataBean.getImageUrl(), holder.mImgIcon,R.drawable.logo);
}catch(OutOfMemoryError e){
}
return convertView; }
This is the above crash report i am getting , please let me know and suggest me some solution.

Your code fails in a native function named jpeg_start_decompress() in the library libjpeg.so, so my best guess is that you are trying to display a corrupted JPEG file or something like that.
If you have access to the images, I would suggest you to try to open them all on your computer and see if there isn't one that fails to load.

Related

ListView ImageView load same pictures

i have a big problem with my ListViewAdapter.
My listview shows 2 entrys at the same time. Each entry should get a different picture from my server.
The first and the second entrys working fine, but if i'm scrolling down, the next entrys will have the same pictures.
My Code looks like this:
if (viewHolder.imgPic != null) {
String strUrl = mainUrl+list.get(position).getUrl();
new ImageDownload(viewHolder.imgPic).execute(strUrl);
}
I'm checking the view and just doing it, if it's null.
Can someone help me?
Thanks
from your question I can assume that you don't know about the ListView recycling mechanisem
basically, view that that not visible anymore (after user scrolled it away from sight) it been recycled to displayed new item that need to shown. that's the convertView parameter at the getView() method...
probably you are see the same image because the recycled view stays with the same image..
also there is the issue of the asynchronous task (your ImageDownload class) that can finish it execute when the original item that started the request already been recycled.
I recommend you to "dig" as dipper as you can to understand all about ListView - this is one of the most complex and important UI component. reading the post I linked you is a good start.
also this video is very important:
http://www.youtube.com/watch?v=wDBM6wVEO70
Here is my GetView:
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = null;
if(rowResourceId!=R.layout.search_empty_list) {
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflator.inflate(rowResourceId, null);
final ViewHolder viewHolder = new ViewHolder();
viewHolder.textName = (TextView) view.findViewById(R.id.textView1);
viewHolder.imgPic = (ImageView) view.findViewById(R.id.imgPic);
if (viewHolder.imgPic != null) {
String strUrl = mainUrl+list.get(position).getUrl();
new ImageDownload(viewHolder.imgPic).execute(strUrl);
}
view.setTag(viewHolder);
} else {
view = convertView;
}
ViewHolder holder = (ViewHolder) view.getTag();
holder.textName.setText(list.get(position).getName());
} else {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(rowResourceId, parent, false);
TextView textView1 = (TextView) view.findViewById(R.id.textView1);
textView1.setText(list.get(0).getName());
}
return view;
}

android listview after image is updated still use one it has in cache

In my listview i have image and text which can be updated from internet. Images is saved on external memory. When update is happening text is showed correct but image is still old one, the one which is in cache. On update i delete old image and create new one with same name. But unless im clearing app cache, listview will show old image. How could i solve this ?
I also tried to clear cache programmatically but thats causing some other problems.
On postExecute i try call MyListView.getMdataAdapter().notifyDataSetChanged();however it doesnt help.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View view = convertView;
final ViewHolder holder;
Items2 i = items.get(position);
if(convertView==null){
holder = new ViewHolder();
view = inflater.inflate(R.layout.list_row, parent, false);
holder.text = (TextView)view.findViewById(R.id.tvRestList);
holder.image = (ImageView)view.findViewById(R.id.imgList);
view.setTag(holder);
view.setOnTouchListener(this);
}else{
holder = (ViewHolder)view.getTag();
}
holder.pos = position;
Items2 item = (Items2)i;
holder.text.setText(item.name);
imageLoader.displayImage("file:///"+context.getExternalFilesDir(null).toString()+File.separator+String.valueOf(position)+".jpg", holder.image, options);
return view;
}
ImageLoader is Universal Image Loader.

Listview button backround issue while scrolling in Android

I have a Listview which shows Facebook friend image and name.There is a Button on each row on the right side to do some operation withe that particular Facebook friend.The Button can either have 3 backgrounds based on some condition. Those are as Follows,
1.Set the button background to "Background1.png" if that friend is not invited.
2.Set the button background to "background2.png" if that friend is invited.
3.Set the button background to "background3.png" if that friend had completed the survey.
I have some given conditions which checks whether the friend is invited or not.Also for the survey thing.Attached screenshot shows what I need actually.
My problem is the button background changes while scrolling as Listview reuses the position.I cant use general views to show it as number of Facebook friend varies and it will show memory issue.
Below is what I have tried so far. Please guide me how to achieve this.
Code:
#Override
public View getView(int position, View convertView,
ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = mInflater.inflate(R.layout.category_listview, null);
Facebook_FriendImage=(SmartImageView)vi.findViewById(R.id.category_image);
Facebook_FriendName = (TextView) vi.findViewById(R.id.category_name);
invite = (Button) vi.findViewById(R.id.invite);
invite.setTag(position);
if (position==2 || position==3) {
invite.setBackgroundResource(R.drawable.background1);
}
else if (position==5 || position==8) {
invite.setBackgroundResource(R.drawable.background2);
}
else {
invite.setBackgroundResource(R.drawable.background3);
}
//Snippet for loading FB Friend Image
int loader = R.drawable.no_image;
Facebook_FriendImage.setScaleType(ImageView.ScaleType.FIT_XY);
Facebook_FriendImage.setImageUrl(GlobalClass.FACEBOOK_FRIEND_IMAGE_URL.get(position), loader);
//Snippet for Loading FB Friend Name
String unicode=new String(GlobalClass.FACEBOOK_FRIEND_NAME.get(position));
Typeface font= Typeface.createFromAsset(getAssets(), "NotoSans-Bold.ttf");
Facebook_FriendName.setTypeface(font);
Facebook_FriendName.setText(unicode);
return vi;
}
The if conditions I have given here is just for simplification.
solution may be this:
simply delete only condition.
if(convertView == null)
may this help.
you should also try to make new View:
View vi = convertView;
if(vi == null) {
//your code
}
return vi;
Use a Holder to your ListView like this :
public View getView(int position, View convertView,
ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null){
convertView = mInflater.inflate(R.layout.category_listview, null);
holder = new ViewHolder();
holder.Facebook_FriendImage=(SmartImageView)convertView.findViewById(R.id.category_image);
holder.Facebook_FriendName = (TextView) convertView.findViewById(R.id.category_name);
holder.invite = (Button) convertView.findViewById(R.id.invite);
invite.setTag(position);
convertView.setTag(holder);
}
else {
holder = (ViewHolder)convertView.getTag();
}
if (position==2 || position==3) {
holder.invite.setBackgroundResource(R.drawable.background1);
}
else if (position==5 || position==8) {
holder.invite.setBackgroundResource(R.drawable.background2);
}
else {
holder.invite.setBackgroundResource(R.drawable.background3);
}
//Snippet for loading FB Friend Image
int loader = R.drawable.no_image;
holder.Facebook_FriendImage.setScaleType(ImageView.ScaleType.FIT_XY);
holder.Facebook_FriendImage.setImageUrl(GlobalClass.FACEBOOK_FRIEND_IMAGE_URL.get(position), loader);
//Snippet for Loading FB Friend Name
String unicode=new String(GlobalClass.FACEBOOK_FRIEND_NAME.get(position));
Typeface font= Typeface.createFromAsset(getAssets(), "NotoSans-Bold.ttf");
holder.Facebook_FriendName.setTypeface(font);
holder.Facebook_FriendName.setText(unicode);
return convertView;
}
and the class ViewHolder should be like this :
class ViewHolder{
SmartImageView Facebook_FriendImage;
TextView Facebook_FriendName;
Button invite;
}
This is the problem of view recycling i also faced the same problem. Go through link nelow it solved my problem
check box in listview not working properly

Out of memory on a byte allocation

This is the error I am receiving on the Android log, exactly, this is:
08-06 12:16:28.763: E/dalvikvm-heap(27065): Out of memory on a 184-byte allocation.
The "184" depends, sometimes it is 184, sometimes it is 24, other 42......etc....
I was looking everywhere, and this error is common for Activities where loading pictures, my problem is that I am not loading picture, but only text.
My Activity is a ListActivity, where I load data from a DataBase(only text), and after a while, all the time the same error.
Anyone knows how to solve it??
Thanks a lot!
Since you are using a listActivity check if you have implemented the optimizations shown here.
I solved a similar issue with list view by implementing the optimization
Here are some excerpts from the presentation about optimizing a listAdapter
The Slow way
public View getView(int position, View convertView, ViewGroup parent) {
View item = mInflater.inflate(R.layout.list_item_icon_text, null);
((TextView) item.findViewById(R.id.text)).setText(DATA[position]);
((ImageView) item.findViewById(R.id.icon)).setImageBitmap(
(position & 1) == 1 ? mIcon1 : mIcon2);
return item;
}
The Proper way
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item, parent, false);
}
((TextView) convertView.findViewById(R.id.text)).setText(DATA[position]);
((ImageView) convertView.findViewById(R.id.icon)).setImageBitmap(
(position & 1) == 1 ? mIcon1 : mIcon2);
return convertView;
}
The Best Way
static class ViewHolder {
TextView text;
ImageView icon;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_icon_text,
parent, false);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(DATA[position]);
holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
return convertView;
}
Sometimes you can get OutOfMemory error, when you try to execute too long SQL statements (eg, you don't use the String[] argument for the variables in the query, but hard code them in the statement).
Try editing your where statements to field=? format, and specify the variables in the designated query parameter.
See this thread: Sqlite Out of Memory when preparing update statement
If this isn't the problem in your case, than I can't think of anything else with this little information.
In my case, the problem caused by big-size images. I removed some of them (temporarily for test) and the problem solved. Note that in my case, the problem just was in lowest API-level I was trying the app (API 16).
Finally, optimized them for solving the problem permanently.

alternative to gallery widget

Is there any faster alternative to Gallery widget in Android, because Gallery is so slow and lagging, i tryed to use view holder to reuse views, but without result. i used classic method
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.image, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.icon = (ImageView) convertView.findViewById(R.id.ImageView01);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
holder.icon.setImageDrawable(getPicture(items[position]));
return convertView;
}
This is a couple of various galleries created by other and uploaded to GitHub. You might need to checkout them to see how they are and how fast they are.

Categories

Resources