Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.view.InflateException: Binary XML file line #34: Error inflating class pl.droidsonroids.gif.GifImageView #400

Closed
saikat1529 opened this issue Apr 2, 2017 · 7 comments

Comments

@saikat1529
Copy link

Hi,
I have followed your all previous guide like #320 and all others, but still can't get it done. I have attached my stack trace below, please help me to get rid out of it. My device in HTC One M8 with android version 4.4.4

STACK TRACE
FATAL EXCEPTION: main
Process: com.nullpointerbd.iucf, PID: 8779
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nullpointerbd.iucf/com.nullpointerbd.iucf.Activity.SplashScreen}: android.view.InflateException: Binary XML file line #34: Error inflating class pl.droidsonroids.gif.GifImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2439)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$800(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
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:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class pl.droidsonroids.gif.GifImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at com.nullpointerbd.iucf.Activity.SplashScreen.onCreate(SplashScreen.java:39)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
at android.app.ActivityThread.access$800(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:157) 
at android.app.ActivityThread.main(ActivityThread.java:5633) 
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:896) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712) 
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 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at com.nullpointerbd.iucf.Activity.SplashScreen.onCreate(SplashScreen.java:39) 
at android.app.Activity.performCreate(Activity.java:5312) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
at android.app.ActivityThread.access$800(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:157) 
at android.app.ActivityThread.main(ActivityThread.java:5633) 
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:896) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02006a a=-1 r=0x7f02006a}
at android.content.res.Resources.loadDrawable(Resources.java:2113)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.(ImageView.java:129)
at android.widget.ImageView.(ImageView.java:119)
at pl.droidsonroids.gif.GifImageView.(GifImageView.java:40)
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 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at com.nullpointerbd.iucf.Activity.SplashScreen.onCreate(SplashScreen.java:39) 
at android.app.Activity.performCreate(Activity.java:5312) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
at android.app.ActivityThread.access$800(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:157) 
at android.app.ActivityThread.main(ActivityThread.java:5633) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515)

My App Level build.gradle file:
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.nullpointerbd.iucf"
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions{
checkReleaseBuilds false
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile files('libs/YouTubeAndroidPlayerApi.jar')
//Material Design Library
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile "com.android.support:support-v4:+"

compile 'ch.acra:acra:4.5.0'

//Enable Multidex for GIF Image Drawable
compile 'com.android.support:multidex:1.0.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.okio:okio:1.6.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.github.johnkil.print:print:1.2.2'
//Slider Library
compile 'com.daimajia.slider:library:1.1.5@aar'

//GIF Show Library
compile 'com.nineoldandroids:library:2.4.0'



compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'

//Image Loading Library
compile 'com.squareup.picasso:picasso:2.5.2'

//JSOUP Library for web scraping
compile 'org.jsoup:jsoup:1.9.1'

compile 'com.github.bumptech.glide:glide:3.7.0'

// retrofit, gson, okhttp
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
testCompile 'junit:junit:4.12'

}

@koral--
Copy link
Owner

koral-- commented Apr 3, 2017

Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02006a a=-1 r=0x7f02006a}
It does not seem to be related to multidex. Could you paste XML framgent with GifImageView?

@saikat1529
Copy link
Author

Thanks for your reply. Please follow my xml layout below

<ImageView
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:src="@drawable/logo_with_border"
    android:scaleType="fitXY"
    android:layout_gravity="center" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="IUCF"
    android:textSize="@dimen/btn_font_size"
    android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2"
    android:padding="10dp"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="Inter University Cultural Festival"
    android:textSize="@dimen/font_size"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"/>


<pl.droidsonroids.gif.GifImageView
    android:id="@+id/loader_image"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/loader"
    android:layout_marginTop="10dp"
   android:layout_gravity="center"
    />

In my drawable folder i have loader.gif file with 120x120 size downloaded from loading.io website.

@koral-- koral-- removed the needs info label Apr 3, 2017
@koral--
Copy link
Owner

koral-- commented Apr 3, 2017

It looks very odd. Could you try creating drawable with GifDrawable#createFromResource and set it in ImageView instead of android:src?

@saikat1529
Copy link
Author

Hi,
Thanks for your response. But i found out the problem. When i added the gif file inside my drawable accidentally it was only copied to folder drawable-v21 and as my device was in api level 19, hence the file was missing for that version. Which was causing error on the time of inflate layout. Sorry for inconvenience.

@koral--
Copy link
Owner

koral-- commented Apr 4, 2017

No problem.

@koral-- koral-- closed this as completed Apr 4, 2017
@techview51
Copy link

Same issue: Solved.
My image files were in the "drawable-v24" folder. I copied them to the "drawable" folder too. Problem solved.

@Ahmed92Azz
Copy link

I think casued problem , (android:scaleType="fitXY") or (android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants