Azure / azure-notificationhubs-android

Android SDK and Samples for Azure Notification Hubs
Apache License 2.0
33 stars 63 forks source link

[BUG] App is crashing on NotificationHub.Start method on Android 4.4 and Android 5.1 #144

Closed amandshahu closed 4 years ago

amandshahu commented 4 years ago

I am using notification hub SDK version 1.1.1, but the app is crashing on NotificationHub.start method, this issue reproduced on Android 4.4 and 5.1. It is working fine above Android 5.1

java.lang.ExceptionInInitializerError
        at com.microsoft.windowsazure.messaging.notificationhubs.NotificationHubInstallationAdapter.<init>(NotificationHubInstallationAdapter.java:55)
        at com.microsoft.windowsazure.messaging.notificationhubs.NotificationHubInstallationAdapter.<init>(NotificationHubInstallationAdapter.java:50)
        at com.microsoft.windowsazure.messaging.notificationhubs.NotificationHub.start(NotificationHub.java:106)
        at com.renatus.helios.views.activities.LoginActivity.onCreate(LoginActivity.java:105)
        at android.app.Activity.performCreate(Activity.java:6010)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
        at android.app.ActivityThread.access$800(ActivityThread.java:155)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5343)
        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:905)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
     Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 4:
    (?<key>[^=]+)=(?<value>[^;]+);?
        ^
        at java.util.regex.Pattern.compileImpl(Native Method)
        at java.util.regex.Pattern.compile(Pattern.java:411)
        at java.util.regex.Pattern.<init>(Pattern.java:394)
        at java.util.regex.Pattern.compile(Pattern.java:381)
        at com.microsoft.windowsazure.messaging.notificationhubs.ConnectionString.<clinit>(ConnectionString.java:7)

To Reproduce Steps to reproduce the behavior: It will easily reproducible on android 4.4 and android 5.1

Code Snippet

NotificationHub.start(this.getApplication(), BuildConfig.HUB_NAME,
                BuildConfig.HUB_STRING);

Expected behavior The app should work on all version of android

Setup (please complete the following information):

Additional context Add any other context about the problem here.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

marstr commented 4 years ago

Thanks for filing this, @amandshahu. The following line must be using a Regex feature that is not available in older versions of Android: https://github.com/Azure/azure-notificationhubs-android/blob/da3d304d72bfd5b357e47a481ae274aeb4421f98/notification-hubs-sdk/src/main/java/com/microsoft/windowsazure/messaging/notificationhubs/ConnectionString.java#L7

We'll triage and release a fix for this.

marstr commented 4 years ago

Without looking into it too deeply, my guess is that named capture groups are not supported in earlier versions of Android.

marstr commented 4 years ago

Quick update: I was able to repro this locally and am working on a fix.

marstr commented 4 years ago

I've confirmed that with the patch above, this issue no longer repros.

marstr commented 4 years ago

Fix is published in v1.1.2, please try it out. :)

amandshahu commented 4 years ago

Thank you @marstr, It is working now.