Android App Crash & Reboot OS / Phone

I’m been spending a whole weekend trying to hunt down a crash reported by one of my user who is running Samsung J3 on Android Oreo 8.1. The app launch then crash. It also bring down the whole Android OS and rebooted the phone. This is very unusual and because app crash normally won’t bring down the whole OS.

No crash report recorded on App Center (crash analytical tool I used) or Google Play Console which is understandable because whole OS is down). This make the debugging almost impossible since I cannot duplicate this on my phone nor emulator I tried. Since only 1 user reported, I suspect this is very much a isolated case.

After some deep search on the internet. It seem like Samsung Android phone have this cache partition that help app launch faster by caching some data in it. Some time it will become corrupted and causing random problem. Since wiping the cache partition doesn’t wipe any of the user data, I tell my user to give it a try. It work!

Here are the post on how to wipe the cache partition: https://us.community.samsung.com/t5/Phones/How-to-wipe-the-Cache-Partition-on-your-phone-or-tablet/td-p/12662

Xamarin UITest Finished Immediately After Run

I’m trying to rerun a few Xamarin UITest that I created a few months ago in Visual Studio 2017 on Android. As expected, they all failed, but not because of the test is outdated, but the tool is broken.

First thing I discovered that the test finished immediately once it started.

========= Run test finished: 0 run (0:00:00.5110016) ==========

After some search online, new version of Visual Studio messed the test tool by adding something new. To revert the changes that affect this, go to Tools > Options > Test > General > Active Solution then uncheck “For improved performance, only use test adapters in test assembly folder or as specified in runsettings file.

I have no idea why, but this solution is provide here: https://forums.xamarin.com/discussion/140234/what-causes-ui-tests-to-run-without-getting-a-pass-or-fail

You should also turn change the logging level to diagnostic because you properly need that later.

Everything should be smoonth now, but the test failed immediately with the following information (not error).

The running adb server is incompatible with the Android SDK version in use by UITest

Instead of messing with the platform-tools folder by downgrading adb version suggested by many. The actual solution is pretty simple, open the Android SDK, and delete any folder with platform-tools.oldXXXXXXXX (those X are number).

Source: https://stackoverflow.com/questions/52254881/cannot-run-xamarin-ui-test-on-xamarin-forms-error-system-exception

While switching back to Visual Studio Mac try to run the UITest on iOS simulator, I hitted with another problem. The iOS emulator failed to launch and no output is given. In turn out the old Xamarin.UITest version 2.2.6 I used is not compatible with XCode 10, by upgrading it to version 2.2.7. It run smooth again.

Gosh, so many trouble.

UnsatisfiedLinkError in Android 8.0

I received quite a number of crash reported in my Xamarin.Android app reported in Play Console with the following stack trace:

java.lang.UnsatisfiedLinkError
  at mono.android.Runtime.register (Native Method)
  at md5dd7a5194eb3bf67181b6a5c267c0f7e7.PushNotificationMessagingService. (PushNotificationMessagingService.java:15)
  at java.lang.Class.newInstance (Native Method)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:3470)
  at android.app.ActivityThread.-wrap4 (Unknown Source)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1748)
  at android.os.Handler.dispatchMessage (Handler.java:108)
  at android.os.Looper.loop (Looper.java:206)
  at android.app.ActivityThread.main (ActivityThread.java:6733)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:845)

 

I have no idea what crashed. The only thing it point to is the push notification services in the app with no additional information. They happen on Android 8.0 and above devices only. Android 8.0 above doesn’t required any special permission to receive notification. No similar crash reported in App Center (I use App Center as my crash reporting tool). Search online doesn’t return me anything meaningful. So I just ignore the error since no user complain anything to me.

Then today I found out that Android 8.0 and above required channel id when showing notification else it will crash in the background. Oh, snap, this is the problem! If you have simiar crash stack trace, this is probably the answer: https://blog.xamarin.com/android-oreo-notification-channels/

Failed to Launch Android Device Monitor

Every time I reformatted my machine and reinstall back Android Studio / Visual Studio. There are always some components in Android development tools are broken. It work perfectly previous, but now it doesn’t work on new freshly installed machine. It is always a new problem. This is annoying.

When I launch Android Device Monitor from Visual Studio 2017 or launch the android device monitor manually from executable. The following error pop up.

Failed to load the JNI shared library “C:\Program Files\Java\jdk1.8.0_181\bin\..\jre\bin\server\jvm.dll”

Depend on your installed JDK version, the error message might be different.

This is because Visual Studio tried to launch the x86 version of Android Device Monitor, while my machine only have x64 Java SDK / JDK installed, so it complain that. Unlike previous Visual Studio which install x86 JDK, all new Visual Studio now come with x64 JDK only.

Continue reading Failed to Launch Android Device Monitor

iOS WkWebview Return A Blank Screen / White Screen

Try to code your first example of WkWebview / UIWebView in your iOS app always return a blank screen or white screen? You are not alone. Apparently since iOS 9, all HTTP / non-secure web connection is block by default. It is something call App Transport Security (ATS).

You can add the following configuration into Info.plist to allow WkWebview / UIWebView to load HTTP / non-secure web page:

<key>NSAppTransportSecurity</key>
<dict>
    <key> NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

Or you can completely disable App Transport Security by

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Source: https://developer.xamarin.com/guides/ios/application_fundamentals/ats/

Xamarin Test Recorder Installation: VSIXInstaller.NoApplicableSKUsException

I came across Xamarin Test Recorder a few days ago, and feel that it really can solve the pain I have with Appium which need a lot of work to write a single test. Give it a try to install but it fail with the following message below and no body in the marketplace review seem to know why and leave a one star review. Because no body care to read the description!

Continue reading Xamarin Test Recorder Installation: VSIXInstaller.NoApplicableSKUsException