Crazycriss
Crazycriss

Reputation: 315

ImageView is Crashing The Application

This application works perfectly on my android 2.1 but when i use it on my Galaxy S3 4.1.1 it doesnt work at all and crashed

The LogCat

12-22 22:38:39.756: E/AndroidRuntime(25460): FATAL EXCEPTION: main
12-22 22:38:39.756: E/AndroidRuntime(25460): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.TripleC.twenty20/com.TripleC.twenty20.MainActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ImageView
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2088)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.app.ActivityThread.access$700(ActivityThread.java:139)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.os.Looper.loop(Looper.java:137)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.app.ActivityThread.main(ActivityThread.java:4918)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at java.lang.reflect.Method.invokeNative(Native Method)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at java.lang.reflect.Method.invoke(Method.java:511)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at dalvik.system.NativeStart.main(Native Method)
12-22 22:38:39.756: E/AndroidRuntime(25460): Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ImageView
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)

Also here is my XML build, i see that it is the picture i have put up but i dont know what about the picture is the problem, if i delete it, the app works perfectly but i need the picture there

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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Welcome To the Beta Version of 20/20's Youth Ministry New App"
android:gravity="center"
android:id="@+id/fragment_main_textview" 
android:textColor="#FFFFFF"
android:textSize="10pt"
/>

<ImageView 
android:layout_width="120pt"
android:id="@+id/mainLogo" 
android:layout_height="120pt"
android:background="@drawable/glasses"
android:layout_gravity="center"
/>

</LinearLayout>

It is now saying this

12-22 23:16:31.465: A/libc(3371): Fatal signal 11 (SIGSEGV) at 0x000009a4 (code=1), thread 3371 (ripleC.twenty20)

Upvotes: 2

Views: 10735

Answers (6)

user3163284
user3163284

Reputation: 11

I faced the same problem, but I found the image with depth 8 cause the problems. So I use another image with other depth than 8.

enter image description here

Upvotes: 1

HUSSAIN FALAAH
HUSSAIN FALAAH

Reputation: 11

It is just a simple thing. Resolution/Dimension of the image file is too high. Just changing the resolution will fix it for sure. That is the only problem here.

Upvotes: 0

Hamad
Hamad

Reputation: 5152

the problem is in the size of the image you gonna have to set for imageview, As you already mentioned that in previous versions,it works perfect,but in newer versions,it is crashing you app,it means you haven;t added images in drawable folder, add drawable folder in your resources and add glasses image in that folder,then clean your project and run your application,your problem would be solved then.

your error is at:

Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ImageView
12-22 22:38:39.756: E/AndroidRuntime(25460):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-22 22:38:39.756: E/AndroidRuntime(25460):    

and exception is generated on line #20 and it is image view.

Upvotes: 2

Amit
Amit

Reputation: 381

Are you scaling the layout it is null pointer that means Android is not able to find your Drawable id(glasses), put same image in your scaled drawables or simply create a drawable folder and keep glasses in drawable folder. then it should work fine.

Upvotes: 1

ZORRO_BLANCO
ZORRO_BLANCO

Reputation: 909

I think the problem in the size of the image you gonna have to set the scale to fit XY, and set the layout width and height to "wrap_content" also the layout_centerInParent to true, I believe you need all these properties to be set not only one of them:

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:scaleType="fitXY"

I hope that will help you ...

Upvotes: 0

CR Sardar
CR Sardar

Reputation: 1018

Because of resource dpi problem, please put resources in drawable & layout directory & try, no extension like drawable-hdpi.

Upvotes: 0

Related Questions