sayyam/carouselview

Suddenly can't use com.synnapps.carouselview.CarouselView (Error inflating class com.synnapps.carouselview.CarouselView)

KKTadena opened this issue · 4 comments

At first i'm able to use and test my app fine but I suddenly received this error and never able to use it again, even adding this 4 line in my XML it will already crash. please help. I can't resolve the issue,
tried: clean, rebuild, redownload gradle, invalidate/restart. I'm out of options right now. I also added -keep class com.synnapps.carouselview.** { *; } in proguard-rules.pro

<com.synnapps.carouselview.CarouselView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</com.synnapps.carouselview.CarouselView>

Here's the full error

--------- beginning of crash

2019-03-21 19:37:59.774 7640-7640/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app., PID: 7640
java.lang.RuntimeException: Unable to start activity ComponentInfo{com..app./com..app..modules.activities.SplashScreenActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class com.synnapps.carouselview.CarouselView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class com.synnapps.carouselview.CarouselView
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.synnapps.carouselview.CarouselView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com..app..modules.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:40)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.NoSuchFieldError: No field containerViewPager of type I in class Lcom/synnapps/carouselview/R$id; or its superclasses (declaration of 'com.synnapps.carouselview.R$id' appears in /data/app/com..app.-1/split_lib_slice_8_apk.apk)
at com.synnapps.carouselview.CarouselView.initView(CarouselView.java:88)
at com.synnapps.carouselview.CarouselView.(CarouselView.java:69)
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com..app..modules.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:40) 
at android.app.Activity.performCreate(Activity.java:6682) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6121) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 

Imported as library and I get this error
Caused by: java.lang.NoSuchFieldError: No field containerViewPager of type I in class Lcom/synnapps/carouselview/R$id; or its superclasses (declaration of 'com.synnapps.carouselview.R$id' appears in /data/app/com.grailconcept.app.Grail-2/split_lib_slice_4_apk.apk)

help us :(

after you add : -keep class com.synnapps.carouselview.** { *; } in proguard-rules.pro
you need add : useProguard true

like this in build.gradle
android {
//..
buildTypes {
release {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}

This problem happened to me, I included -keep ...... in proguard-rules.pro and it didn't work, the error was in the parameters passed in the XML I was bringing them from the Resources, I put the values ​​in HardCode and it worked, I don't know why happens, I hope someone serves