Kotlin: ArrayIndexOutOfBoundsException during converting DispatchTask to string - android

We have released our first Kotlin pieces into production and we are getting crashes with this stacktrace:
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at kotlin.jvm.internal.ReflectionFactory.renderLambdaToString(ReflectionFactory.java:47)
at kotlin.jvm.internal.Reflection.renderLambdaToString(Reflection.java:80)
at kotlin.jvm.internal.Lambda.toString(Lambda.kt:22)
at java.lang.StringBuilder.append(StringBuilder.java:202)
at kotlinx.coroutines.experimental.DispatchedContinuation.toString(CoroutineDispatcher.kt:192)
at java.lang.StringBuilder.append(StringBuilder.java:202)
at kotlinx.coroutines.experimental.DispatchTask.toString(CoroutineDispatcher.kt:124)
at java.lang.StringBuilder.append(StringBuilder.java:202)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Google show us this is happening in 100 % on Android 5. Crashlytics/Fabric shows also two crashes from Android 4.4. No crashes from newer Android versions.
I have no idea how to prevent this crash or how to replicate it.
Current version:
org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16

That is a bug in Kotlin reflection. Meanwhile, I'd suggest to upgrade to the latest version of kotlinx.coroutines library (you can find what is the latest version here). Since version 0.17 DispatchTask.toString does not try to covert lambda to string anymore. It's toString implementation is actually more useful now and has more relevant information for debugging purposes.

Related

Noozxoide EIZO-rewire™ PRO crashing under Android 11

since I´ve downloaded the Android 11 update (Samsung Galaxy S10e; also tested with Android SDK´s Emulator running Android 11, same results), the DSP app "Noozxoide EIZO-rewire™ PRO" is always crashing when started. I know that this app was developed for Android 4.0, but it was even working properly on Android 10. I decided to download Android SDK to test in on VM and look at the logcat.
I would like to get the app working because it improves the audio quality perfectly and I don´t know any similar app like this one. I wanted to contact the developers of the app but their e-mail adress does not exist anymore.
I don´t have any experience with developing apk´s, but maybe someone can help me :)
I have already read some logcat explanations and guide to migrating apps to Android 11 on developer.android but it didn´t really help me with this.
Maybe can someone explain to me what´s happening in this logcat part:
2021-02-24 20:21:19.648 10997-10997/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.noozxoidelabs.eizo.rewirepro, PID: 10997
java.lang.RuntimeException: java.lang.NoSuchMethodException: android.media.audiofx.AudioEffect.setParameter [class [B, class [B]
at com.noozxoidelabs.eizo.rewirepro.VSPCoreEngine.updateDsp(VSPCoreEngine.java:231)
at com.noozxoidelabs.eizo.rewirepro.VSPCoreEngine$4.onCallStateChanged(VSPCoreEngine.java:129)
at android.telephony.PhoneStateListener$IPhoneStateListenerStub.lambda$onCallStateChanged$10(PhoneStateListener.java:1185)
at android.telephony.-$$Lambda$PhoneStateListener$IPhoneStateListenerStub$6czWSGzxct0CXPVO54T0aq05qls.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NoSuchMethodException: android.media.audiofx.AudioEffect.setParameter [class [B, class [B]
at java.lang.Class.getMethod(Class.java:2072)
at java.lang.Class.getMethod(Class.java:1693)
at com.noozxoidelabs.eizo.rewirepro.VSPCoreEngine.updateDsp(VSPCoreEngine.java:226)
at com.noozxoidelabs.eizo.rewirepro.VSPCoreEngine$4.onCallStateChanged(VSPCoreEngine.java:129) 
at android.telephony.PhoneStateListener$IPhoneStateListenerStub.lambda$onCallStateChanged$10(PhoneStateListener.java:1185) 
at android.telephony.-$$Lambda$PhoneStateListener$IPhoneStateListenerStub$6czWSGzxct0CXPVO54T0aq05qls.run(Unknown Source:6) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
Thanks in advance
PS: sorry for my misstakes in English :)
From the Google Play Store comments for that app, support is no longer available, and due to framework code changes won't work on modern Android
Similar to: Compile error: Cannot find symbol AudioEffect::setParameter in Android Studio
A quick check of the source shows that in old version of Android:
https://android.googlesource.com/platform/frameworks/base/+/5bb8f80/media/java/android/media/audiofx/AudioEffect.java
No annotation was on setParameter(...)
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android11-d1-release/media/java/android/media/audiofx/AudioEffect.java
While in newer ones the setParameter(...) functions is now hidden by #TestApi and throw an exception if not initialized correctly.
Any fix will require developer to update code.
I have the solution you're looking for. I downloaded an app from the Play Store called App Cloner, and ran Noozxoide through this program to create a cloned apk. The cloned app installed perfectly and worked fine on Android 11.

Android app built with "make project" crashes, but not when installed with "Run"

We're building an app which uses HighCharts Android wrapper library*.
During development, the app is installed on devices/emulators via the Run command, and everything works fine.
But, when making a build view Make Project, Generate Signed APK, or builds produced by CI/DC Pipelines - the app always crashes.
The crash occurs somewhere when Highcharts calls Gson (which needs to be externally provided as a dependancy for it in Gradle build file). Gson then throws a java.lang.ArrayIndexOutOfBoundsException exception. (stacktrace below)
what it's not:
Not related to Android version. tested on API's 29, 25, 23
Not device related. Happens on Physical devices and emulators running clean android.
Not Proguard related (I think) - happens also on debug builds, and also aggressive keep statements were added just to be on the safe side.
Same charts work properly on our website and iOS app.
Maybe related:
Highcharts Android is not yet compatible with Hilt DI, which is deeply embedded in our code. Apparently, Highcharst expects the Context provided to it's View constructor to be of Activity type, which is broken with Hilt since in injects a FragmentContextWrapper into Fragments annotated with #AndroidEntryPoint.
description and workaround here
What I'm trying to understand:
What could be the difference in the output .APK built during Run and Make?
A full description of the crash, with example code, can be found here
* HighCharts is a JS charting library. The Android Highcharts library is a Java wrapper for JS that runs on a custom WebView. The API is also Java Objects and functions wrapping JS code.
Stacktrace:
2020-07-30 09:39:25.679 5627-5627/com.app.android.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.android.debug, PID: 5627
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.google.gson.internal.$Gson$Types.getGenericSupertype($Gson$Types.java:240)
at com.google.gson.internal.$Gson$Types.getSupertype($Gson$Types.java:272)
at com.google.gson.internal.$Gson$Types.getCollectionElementType($Gson$Types.java:290)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:52)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:56)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:208)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:145)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:208)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:145)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:208)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:145)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:208)
at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:145)
at com.google.gson.Gson.toJson(Gson.java:669)
at com.google.gson.Gson.toJson(Gson.java:648)
at com.google.gson.Gson.toJson(Gson.java:603)
at com.google.gson.Gson.toJson(Gson.java:583)
at com.highsoft.highcharts.core.i.a(SourceFile:8)
at com.highsoft.highcharts.core.f.c(SourceFile:2)
at com.highsoft.highcharts.core.HIChartView$q0.update(SourceFile:4)
at java.util.Observable.notifyObservers(Observable.java:163)
at java.util.Observable.notifyObservers(Observable.java:115)
at com.highsoft.highcharts.core.HIFoundation$a.update(SourceFile:4)
at java.util.Observable.notifyObservers(Observable.java:163)
at java.util.Observable.notifyObservers(Observable.java:115)
at com.highsoft.highcharts.common.hichartsclasses.HISeries.setData(SourceFile:3)
at com.app.android.ui.customviews.hicharts.LineGraphChart$applyDataSet$1.run(LineGraphChart.kt:256)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Uri.java line 475 android.net.Uri$StringUri.<init> com.google.android.gms.ads

I'm getting an error from different device versions (Android 5 - Android 8) since I use ads:
implementation 'com.google.android.gms:play-services-ads:16.0.0'
My error looks like this:
Fatal Exception: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:475)
at android.net.Uri$StringUri.<init>(Uri.java)
at android.net.Uri.parse(Uri.java:437)
at com.google.android.gms.ads.internal.video.a.a(:com.google.android.gms.dynamite_adsdynamite#14366046#14.3.66 (040306-213742215):13)
at com.google.android.gms.ads.internal.video.gmsg.f.a(:com.google.android.gms.dynamite_adsdynamite#14366046#14.3.66 (040306-213742215):148)
at com.google.android.gms.ads.internal.webview.j.a(:com.google.android.gms.dynamite_adsdynamite#14366046#14.3.66 (040306-213742215):293)
at com.google.android.gms.ads.internal.webview.ac.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.google.android.gms.ads.internal.util.e.dispatchMessage(:com.google.android.gms.dynamite_adsdynamite#14366046#14.3.66 (040306-213742215):5)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
any help is apreciated
There is a bug in version 17.0.0 either you're using
implementation 'com.google.android.gms:play-services-ads:17.0.0' //or
implementation 'com.google.firebase:firebase-ads:17.0.0'
You can check this thread for more detail.
According to the post from Mobile Ads SDK Team member, issue has been fixed but there is no ETA as of now.
EDIT
I found that above issue is not related to particular admob version. From last week most of the apps with AdMob start crashing, It doesn't matter what admob version you're using. I think there is issue with server side or how they delivered ads(may be getting null in response) and not handled in AdMob SDK level.
So Currently we've
Issue with Server side
May be some issue in version 17.0.0
Issue already submitted to Mobile Ads SDK team so we've only option to wait for server side fixes or we may get another release after 17.0.0.
I also encountered this issue when I upgraded my ads dependency to the latest version, to find a proper solution keep checking this thread as mentioned by #Aryan in other answer. As a workaround for now you can use the following dependency:
implementation 'com.google.android.gms:play-services-ads:15.0.0'
this will keep the crash from occurring.

Unexplainable crash error

My app crashes when I try to run it. I don't know what could be causing this error... It might be related to my previous question but that post wasn't very good so I'll post the new error here.
FATAL EXCEPTION: main
Process: com.myapp, PID: 12693
java.lang.NoSuchFieldError: No static field AppCompatTheme of type [I in class Landroid/support/v7/appcompat/R$styleable; or its superclasses (declaration of 'android.support.v7.appcompat.R$styleable' appears in /data/data/com.myapp/files/instant-run/dex/slice-slice_4_13f90a0ab4d497a8a87e7463d225d6b3993606ba-classes.dex)
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:336)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.myapp.activity.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:6374)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2743)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2855)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
I can't find any information on this error anywhere else, which is really weird.
I ran in to this error now when upgrading my build tools from 23.0.1 to 23.0.2. I spent an hour investigating how I can solve this problem (I did several cleans and rebuilds and none worked).
Eventually, I took 19lymers advice and deleted the app and reinstalled it and then it got fixed.
EDITED:
I don't know whether this is also related or not but before I did the deletion, my app was already buggy - icons which were suppose to be displayed in one location ended up displaying in another location. I think the resource.xml got corrupted. When that happens, best to delete and reinstall. That's the quickest way to solve this issue.

Is there a workaround for using espresso with Lollipop (Android 21)?

Attempting to run a test with UI-related code using espresso (i.e. GoogleInstrumentationTestRunner) on a Nexus 7 with Lollipop gives the following error:
java.lang.IllegalStateException: This message cannot be recycled because it is still in use.
at android.os.Message.recycle(Message.java:279)
at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:468)
at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:337)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInteraction.java:94)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
This has apparently been a known issue for several months but since there have been no commits since January 8, it is unknown whether there will be an official fix.
There is a comment in the discussion thread that states
Just removing message.recycle(); seems to fix it...
Is this a valid workaround? If not, what would the correct fix be?
UPDATE: Use Espresso 2.0 for Lollipop support
https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions
Yes, if you remove "message.recycle(); " and rebuild it will solve that problem.
The Espresso team announced at GTAC that the next release of Espresso will be in AOSP before too long. See video here: https://www.youtube.com/watch?v=aHcmsK9jfGU
( I was the original poster of that issue you referenced )
UPDATE:
// you will want to keep it for older API versions
if ( SDK_INT < 21 ){
message.recycle();
}

Categories

Resources