NoClassDefFoundError - Only on marshmallow - java

After a recent commit, my app started crashing on marshmallow. I added a custom class, NormalMode, which is created when a service is started. The bug only occurs when this service is started.
I tried looking into the 65K limit and tried to used multidex, but it didn't make a difference. I also installed a plugin to tell me how many methods I use, it found 54996 methods.
Here is a sample of the logcat, running an emulator:
02-15 18:00:44.428 8783-8783/com.vivescere.beacon I/art: Rejecting re-init on previously-failed class java.lang.Class<com.vivescere.beacon.emitter.mode.NormalMode>
02-15 18:00:44.429 8783-8783/com.vivescere.beacon D/AndroidRuntime: Shutting down VM
02-15 18:00:44.429 8783-8783/com.vivescere.beacon E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vivescere.beacon, PID: 8783
java.lang.NoClassDefFoundError: com.vivescere.beacon.emitter.mode.NormalMode
at com.vivescere.beacon.emitter.EmitterService.switchMode(EmitterService.java:328)
at com.vivescere.beacon.emitter.EmitterService.start(EmitterService.java:289)
at com.vivescere.beacon.emitter.EmitterService.onStartCommand(EmitterService.java:163)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3010)
at android.app.ActivityThread.-wrap17(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-15 18:00:48.441 8783-8783/com.vivescere.beacon I/Process: Sending signal. PID: 8783 SIG: 9
I tried removing the class in question, but it just slows down the error, which now happens when creating an instance of the next custom class I have.

Related

Android crashes on start

My app was working fine, until it crashed once and can't run again only on android. IOS is working fine.
build doesn't catch any error, but when I start it on android studio I get these error log.
enter image description here
E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage not null
E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.gamo, PID: 17096
java.lang.AssertionError: No source URL loaded, have you initialised the instance?
at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:35)
at com.facebook.react.modules.debug.SourceCodeModule.getTypedExportedConstants(SourceCodeModule.java:39)
at com.facebook.fbreact.specs.NativeSourceCodeSpec.getConstants(NativeSourceCodeSpec.java:35)
at com.facebook.react.bridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:129)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:923)
I/Process: Sending signal. PID: 17096 SIG: 9
I already tried gradlew clean, cache clean, enable hermes = true

Android studio not showing exception Class and line numbers

I've been using android studio for a while and whenever an exception occurs the information shown in the stacktrace does not contain the class in which the error occured or the line number. It is not even colored blue like it is supposed to. Here's an example of a stacktrace that is thrown:
ava.lang.StringIndexOutOfBoundsException: length=2; index=3
at java.lang.String.indexAndLength(String.java:579)
at java.lang.String.substring(String.java:1438)
at com.patriceandala.myapplication.utils.D.a(SourceFile:101)
at com.patriceandala.myapplication.utils.D.a(SourceFile:29)
at com.patriceandala.myapplication.utils.B.a(SourceFile:77)
at d.b.a.a.run(SourceFile:46)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
It only shows 'SourceFile' yet I don't have a class with that name. How can I fix this?
Disable ProGuard in debug mode and check.
Proguard is a free Java class file shrinker, optimizer, obfuscator and preverifier. It makes the code unreadable. So disable this in debug mode.

Sensortag20 Program Crashes connecting to bluetooth device

I'm trying to modify this project from android studio 2 but when I try to run the app from Android 4.4.2 and connect to a bluetooth device, it gives these error messages.
06-02 14:51:30.126 12669-12669/com.example.ti.ble.sensortag E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ti.ble.sensortag, PID: 12669
java.lang.IllegalArgumentException: null is not a valid Bluetooth address
at android.bluetooth.BluetoothDevice.<init>(BluetoothDevice.java:564)
at android.bluetooth.BluetoothAdapter.getRemoteDevice(BluetoothAdapter.java:418)
at com.example.ti.ble.common.BluetoothLeService.disconnect(BluetoothLeService.java:635)
at com.example.ti.ble.sensortag.MainActivity.onConnect(MainActivity.java:320)
at com.example.ti.ble.sensortag.MainActivity.onDeviceClick(MainActivity.java:379)
at com.example.ti.ble.sensortag.ScanView$1.onItemClick(ScanView.java:205)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1152)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3014)
at android.widget.AbsListView$3.run(AbsListView.java:3865)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5341)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
The project can be found here SensorTag20 Project. How do I fix these problems?
Turns out, I just needed to restart the device everytime I reprogram it.

java.lang.RuntimeException: Android Runtime error [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 7 years ago.
I am new to development of android and i don't have a fair idea how to read logcat. I am trying to develop android webview application but ran into these errors.
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: com.tech.neucial, PID: 25698
E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tech.neucial/com.tech.neucial.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2329)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:147)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5256)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
E/AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference
E/AndroidRuntime: at com.tech.neucial.MainActivity.onCreate(MainActivity.java:39)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
E/AndroidRuntime: ... 10 more
I have tried every possible way to understand but no resolve.
Here is the source code.
https://www.mediafire.com/?28yu5r0y7o19383
PS: i am uploading whole source because i don't know which file has cause the issue and there have been 5 or 6 files which i can't paste here.
Thanks.
Use getSupportActionBar() method instead of getActionBar() inside onCreate of MainActivity

MapActivity ClassDefNotFoundException at runtime

My Activity extends from MapActivity, I have descried it correctly in the manifest, I have put the <uses-library> tag inside the <application> tag I am building with goole apis library and the maps.jar is there only one time(no duplicates) and the app runs and works perfect on most devices.
However I got a crash report with ClassDefNotFoundException which occurred on ZTE Blade device with Android 2.1. I am building with google apis 2.1
Does anyone have suggestions for that?
I am providing the stack trace too:
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2165)
at android.view.View.performClick(View.java:2506)
at android.view.View$PerformClick.run(View.java:9112)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at android.view.View$1.onClick(View.java:2160)
... 11 more
Caused by: java.lang.NoClassDefFoundError: com.testing.asd.android.ui.InfoActivity
at com.testing.asd.android.ui.HomeScreen.onClick(HomeScreen.java:60)
... 14 more
com.testing.asd.android.ui.InfoActivity extends MapActivity. The problem is only on one device so far. I tested it on Android 2.3 and 4.2 and it is ok there.
I'm not sure if this is the case with the ZTE Blade, but there are some devices (such as the Kindle Fire) that don't have the Google APIs. I think these phones will show a NoClassDefFoundError if your app uses MapView.

Categories

Resources