NullReferenceException in System.Threading.Tasks.RangeWorker.FindNewWork in Android Xamarin app
xamarin-android release notes
xamarin android download
xamarin android source
xamarin android sdk
xamarin android samples github
assembly not found for framework xamarin android v10 0 support
In my Android native app created with Xamarin, I get the following crash report in HockeyApp:
Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at System.Threading.Tasks.RangeWorker.FindNewWork (System.Int64& nFromInclusiveLocal, System.Int64& nToExclusiveLocal) [0x00000] in <8f1acca5a43d45c5b8d35add5a11806a>:0 at System.Threading.Tasks.RangeWorker.FindNewWork32 (System.Int32& nFromInclusiveLocal32, System.Int32& nToExclusiveLocal32) [0x00000] in <8f1acca5a43d45c5b8d35add5a11806a>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0xec919968 + 0x00033> in <8f1acca5a43d45c5b8d35add5a11806a>:0
I cannot figure out what is causing this exception since the stack trace only contains .net code. I have looked at the framework's source code to see if I could make sense of it but to no avail.
I have also tried many different searches in my favorites search engines without finding any posts/articles about similar issues.
From the data associated with those crashes, it seems to be an issue happening exclusively on Samsung devices (S8, S8+ and Note8). I cannot be 100% sure that it doesn't affect other devices but I only have crash reports for those.
Any idea what could cause those crashes? Am I doing something wrong with threading, maybe with cancellation tokens? Are there conditions I am not handling correctly?
Any help to further troubleshoot this issue would be very welcomed.
I understand that there is not much to go by but being that this is the only stacktrace I get in HockeyApp and I cannot repro, I have no idea what code causes this.
What I am looking for is more a clue about what could cause Mono threading code to have a null reference exception when I am not managing the threads myself. Or maybe this stacktrace is just a red herring and I need to be looking in other places?
What caught my attention was the FindNewWork32 call -- link for the .NET implementation. Your app may be compiled for 32-bit architecture, and those Samsung devices you mentioned have a 64-bit processor.
This Microsoft paper shows how to target an app to one or more Android-supported CPU architectures. You may need to target multiple platforms:
To target multiple CPU architectures, you can select more than one ABI (at the expense of larger APK file size). You can use the Generate one package (.apk) per selected ABI option (described in Set Packaging Properties) to create a separate APK for each supported architecture.
You do not have to select arm64-v8a or x86_64 to target 64-bit devices; 64-bit support is not required to run your app on 64-bit hardware. For example, 64-bit ARM devices (such as the Nexus 9) can run apps configured for armeabi-v7a. The primary advantage of enabling 64-bit support is to make it possible for your app to address more memory.
Xamarin.Android 10.1, Xamarin.Android 10.1 release notes. 02/11/2020; 27 minutes to read Android apps no longer worked, resulting in server-side System. The new specialized task reduced the time for the _LinkAssembliesNoShrink target from about 340 System.NullReferenceException incorrectly prevented building in some scenarios 8 NullReferenceException in System.Threading.Tasks.RangeWorker.FindNewWork in Android Xamarin app Aug 27 '18 7 Determining which classes would benefit most from unit testing? Mar 17 '10
You should call
.Wait() soon after callback. If you do it before the Context objects might go away and if your code is accessing those Context objects will be arbitrarily null (removed).
If you call
Task.Wait() it would block the thread and then throw an AggregateException once the worker throws it. Try using try catch block to handle exception.
JavaProxyThrowable not always happening due to calling service there might be your activity null some where. You should check null before using activity context.
java - java, A queue system is a natural fit for a pull-based system. The processor can in System.Threading.Tasks.RangeWorker.FindNewWork in Android Xamarin app. This only occurs on Android. I have a listview on a page in my app that is producing a System.NullReferenceException. This happens when its page is not at the top of the navigation stack. Stack trace: [MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object.
I know this answer is not specific for your issue, but when you are dealing with an exception message, which is so brief, it's always a good idea to check system-wide logging. In case of Android, you might get more information using
dmesg command (which is giving you the content of
`NullReferenceException` on AuthenticationRequestConfiguration , NullReferenceException: Object reference not set to an instance of an object at System.Threading.Tasks.RangeWorker.FindNewWork (System. Version of Xamarin: 4.8.188 Versions of other things you are using: Steps to reproduce the Behavior. Version previous to SDK 25 in android was working fine. After updated the SDK and Plugin version, it stopped working. Using FormsAppCompatActivity in Android. Expected Behavior. Not block the app and allow to use camera. Actual Behavior
ERROR: System.NullReferenceException: Xamarin.Forms.Core , smstuebe added bug os:Android labels on Nov 28, 2017 TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] After updated my project with the last version on Xamarin.Forms (220.127.116.1142), android version crashes on startup when android app call LoadApplication(new App()) method. Here is application output (attached follows full log): [MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] System.NullReferenceException: Object reference not set to an instance of
Forms(18.104.22.1689983), I cleaned the solution, deleted the app from my devices and of Xamarin Forms; IDE: Platform Target Frameworks: iOS and Android Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks. Xamarin.Android 9.0 is based on the open-source Xamarin.Android repositories: Core JNI interaction logic is in the Java.Interop repo; Android bindings and MSBuild tooling are in the xamarin-android repo. Chat is in the xamarin/xamarin-android Gitter channel. Related Articles
Xamarin.Forms is an open source mobile UI framework from Microsoft for building iOS, Android, & Windows apps with .NET from a single shared codebase. Whether you want a consistent look across platforms or prefer native look and feel, Xamarin.Forms will get you up and running in no time.
- Please either provide a minimal reproducible example or, without one, it is off-topic and it should be closed.
- May be it's a known bug: github.com/xamarin/xamarin-android/issues/1188
- I believe you were correct as after adding arm64-v8a those exceptions seem to have gone away. It is still too early to be 100% sure as not all my users are on this updated version but things are looking good so far
- Happy to help. Thanks Benoit.
- Thank you for pointing this out. I suspect that I may have some other crashes that could be caused by this. I am definitely going to be looking into it
- Thank you for the suggestions but unfortunately I have been unable to repro those crashes on the emulator or on my devices so I would not be able to look at those logs