CAST - Error inflating class android.widget.ImageButton - android

I have been using ChromeCast in my application before and it was working great. Recently I added Google Cloud Messaging in my application too, and for that I had to update dependency files to
'com.google.android.gms:play-services-cast:8.3.0' and 'com.google.android.gms:play-services-gcm:8.3.0'. But now when client disconnects chromecast we get the following fatal exceptions and the application crashes.
11-23 12:42:49.415 22117-22117/com.jadoo.jadooplus E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.jadoo.jadooplus, PID: 22117
android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.ImageButton
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:315)
at android.app.Dialog.setContentView(Dialog.java:512)
at android.support.v7.app.MediaRouteControllerDialog.onCreate(MediaRouteControllerDialog.java:178)
at android.app.Dialog.dispatchOnCreate(Dialog.java:396)
at android.app.Dialog.show(Dialog.java:268)
at android.support.v4.app.DialogFragment.onStart(DialogFragment.java:399)
at android.support.v4.app.Fragment.performStart(Fragment.java:1813)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:989)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
preceded by an InvocationTargetException and Resources$NotFoundException.
Even now when I change the version anywhere below 7.5.x the code works great. Any ideas why ImageButton is not drawable. I've spent a day at following the stacktrace and today surfing the web, no luck. I haven't found anything useful on the topic.
I applologize for not posting stacktrace from other exception' stacktrace but I can't add more in formatted code.
Edit 1: I can't seem to add any more code here so here's a snapshot:
Edit 2:
I have already tried disabling Proguard, with no effect. The issue persists on a LG G2 d802, a range of Samsung Tabs and Nexus 7. Also I am not using CastCompanionLibrary.

Related

Ionic3 MainActivity ClassNotFoundException on Android 4.4 (Kitkat)

I have an app using Ionic 3 and Cordova-Android 6.4.0. The app works fine on Android API levels > 19 (Kitkat). But running the app on Android 4.4 causes the app to crash at startup with the following exception:
03-21 14:07:40.513 2408-2408/com.xxx.app.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.app.xxx, PID: 2408
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.xxx.app.xxx/com.xxx.app.xxx.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.xxx.app.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.app.xxx-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.xxx.app.xxx-2, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.app.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.app.xxx-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.xxx.app.xxx-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
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:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
I've read about the multidex fix, but I can't apply it to my Ionic app because I can't change the generated Java code to add MultiDex.install(this);.
Does anyone have a solution for this?
The problem and solution are described here.
The java.lang.ClassNotFoundException comes from the fact that the app and its libraries exceed 65,536 methods, and as a result the Java classes are spread across more than one DEX file (Dalvik EXecutable) within the app's APK, i.e. classes.dex, classes2.dex etc. Java classes required to start the app may end up in classes2.dex within the app's APK (as opposed to classes.dex), which can then not be loaded by the Dalvik runtime in Android versions less than 5. From the Android web site:
When building each DEX file for a multidex app, the build tools perform complex decision-making to determine which classes are needed in the primary DEX file so that your app can start successfully. If any class that's required during startup is not provided in the primary DEX file, then your app crashes with the error java.lang.NoClassDefFoundError.
The solution is to identify every class that is referenced at app startup in a text file, as described in the link at the start of my post.
However, the list of required classes is long and hard to establish. I got as far as the classes below, but there are still more startup classes to discover. My solution is to say "Sorry, this app is only available for Android 5 and later".
com/mycompany/app/myapp/MainActivity.class
org/apache/cordova/CallbackMap.class
org/apache/cordova/ConfigXmlParser.class
org/apache/cordova/CordovaActivity$1.class
org/apache/cordova/CordovaActivity.class
org/apache/cordova/CordovaInterface.class
org/apache/cordova/CordovaInterfaceImpl.class
org/apache/cordova/CordovaPreferences.class
org/apache/cordova/CordovaWebViewEngine.class
org/apache/cordova/engine/SystemWebViewEngine.class
org/apache/cordova/LOG.class
org/apache/cordova/PluginEntry.class
org/json/JSONException.class
org/json/JSONObject.class

java.lang.NoClassDefFoundError: com.google.api.client.http.apache.ApacheHttpTransport() on some phones Kinvey Android?

The following error is obtained when running my app using the Kinvey client library:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.api.client.http.apache.ApacheHttpTransport
at com.kinvey.android.Client$Builder.newCompatibleTransport(Client.java:555)
at com.kinvey.android.Client$Builder.<init>(Client.java:609)
at ch.ethz.nervousnet.trialapp04.MainActivity.onCreate(MainActivity.java:94)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2337)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)
at android.app.ActivityThread.access$600(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
The Line in MainActivity class it points to is the following:
Global.setmKinveyClient(new Client.Builder(this.getApplicationContext()).build());
// Client if a library class, not the one I have created
It works on most phones, but on some phones does not work, what could be the cause?
Here is a screen shot of all the libs I have in the project :
Any help is appreciated, thank you.
LoveMeow,
What is the Android version on phones where it is not working? Is it the same version or happens randomly?
Since it is working for you on some phones, all the dependent libraries seem to be added properly. Are there any other warnings that are being thrown?
Thanks,
Pranav
Kinvey Support

Getting uknown error when using mupdf

I've tried to import mupdf to my app, but when I open it, i got some weird error and it force closes. Why? I really don't understand.
this is my logcat:
10-10 15:34:17.802 8657-8657/com.tproductions.Openit E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.tproductions.Openit, PID: 8657
java.lang.UnsatisfiedLinkError: Native method not found: com.artifex.mupdfdemo.MuPDFCore.openFile:(Ljava/lang/String;)J
at com.artifex.mupdfdemo.MuPDFCore.openFile(Native Method)
at com.artifex.mupdfdemo.MuPDFCore.<init>(MuPDFCore.java:68)
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:204)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:303)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
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:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
It looks like something has gone wrong in the native build.
It's probably best to retry that; there are instructions here:
http://www.mupdf.com/doc/how-to-build-mupdf-for-android
and here:
http://git.ghostscript.com/?p=mupdf.git;a=blob_plain;f=platform/android/ReadMe.txt;hb=HEAD
It's probably best to use the git code from master - the latest is 1.6, versions prior to 1.5 are unlikely to build cleanly with the current NDKs.

SlidingUpPanelLayout conflicting with Robolectric

I have a project that uses the SlidingUpPanelLayout but I needed to start writing automated tests using Robolectric. When I introduced Robolectric to the project my Espresso based tests failed to start up. I would get an java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation when the system would try and inflate the SlidingUpPanelLayout.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.marcthomas.testrobolectric/com.marcthomas.testrobolectric.MyActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1929)
at com.marcthomas.testrobolectric.MyActivity.onCreate(MyActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.callActivityOnCreate(GoogleInstrumentation.java:428)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
... 11 more
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)
... 23 more
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at com.sothree.slidinguppanel.ViewDragHelper.<init>(ViewDragHelper.java:392)
at com.sothree.slidinguppanel.ViewDragHelper.create(ViewDragHelper.java:348)
at com.sothree.slidinguppanel.ViewDragHelper.create(ViewDragHelper.java:361)
at com.sothree.slidinguppanel.SlidingUpPanelLayout.<init>(SlidingUpPanelLayout.java:334)
at com.sothree.slidinguppanel.SlidingUpPanelLayout.<init>(SlidingUpPanelLayout.java:263)
... 26 more
If I remove the SlidingUpPanelLayout from my activity_my.xml layout file in the project the tests will run successfully again, so it does seem to be something to do with these two components somehow.
I have created a demo project on github that demonstrates this behaviour. Cloning the code and running ./gradlew connectedAndroidTest will reproduce this issue.
To fix this I needed to add
exclude module: 'support-v4'
to the list of excludes in the app module gradle file where androidTestCompile for robolectric is declared. See explanation below.
This error was down to a Gradle configuration error. The reason is that there are dependencies declared multiple times in the build and one of them needs to be excluded.
To work this out look at the last part of the exception.
ViewDragHelper was the culprit so if in your IDE (Android Studio) open the search for class name (Command-O in OS X) and enter ViewDragHelper. You will see that there are multiple Jars that are returned. You will need to exclude the one that you don’t want.
In this situation we had the android-19 sdk, support-v4-19 and support-v4-20 and library-2.0.1 (the slideuppanellayout library) to solve this I needed to exclude support-v4.
So in the build gradle file for the project where I included robolectric I needed to add the following to the list of excludes.
exclude module: 'support-v4'

My app crashes on lg devices when I am clicking the ad

My app crashes on LG devices when I am clicking the ad (from admob)!. What's the problem?
android.view.InflateException: Binary XML file line #21: Error inflating class <unknown> at
android.view.LayoutInflater.createView(LayoutInflater.java:613) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) at
android.view.LayoutInflater.inflate(LayoutInflater.java:466) at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) at
android.view.LayoutInflater.inflate(LayoutInflater.java:352) at
com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3090) at
com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3150) at
com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1737) at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2683) at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2124) at
android.app.ActivityThread.access$600(ActivityThread.java:138) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:4952) 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:794) at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561) 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:417) at
android.view.LayoutInflater.createView(LayoutInflater.java:587) ... 21 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=7; index=-1 at
android.view.View.<init>(View.java:3638) at
android.view.ViewGroup.<init>(ViewGroup.java:427) at
android.widget.LinearLayout.<init>(LinearLayout.java:176) at
android.widget.LinearLayout.<init>(LinearLayout.java:172) ... 24 more
..................................................................................................
It's issue with LG Optimus L9 P760 device. It occurs only on version 4.1.2, I see it every now and then in my apps. If your application is available on any store and it's serious problem to you remember that you can always disable this device from supported devices.
I don't think there's anything to worry about. In my case the layout isn't complicated so the solution proposed by #Kishan with flattening view hierarchy will not work. It's just manufacturer fault.
This same error was there in my previous application. its because of the internal memory stack of the device (Some thing like RAM) is full. so for overcoming this error see the hierarchy of layout. and see the time of inflating in the hierarchy view if android eclipse IDE. and decrease the hierarchy of the layout. i have solved my issue with this. so you can check this if you can solve by the same solution.
Hope you can understand this solution.

Categories

Resources