【问题标题】:Android Azure notification hub SDK is not working in Android PieAndroid Azure 通知中心 SDK 在 Android Pie 中不起作用
【发布时间】:2019-02-14 06:14:38
【问题描述】:

Android Azure 通知中心 SDK 在 Android Pie 中不工作。

以下是 SDK 详细信息:

mavel 网址:“http://dl.bintray.com/microsoftazuremobile/SDK

依赖关系:

compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4@aar'

compile 'com.microsoft.azure:azure-notifications-handler:1.0.1@aar'

重现步骤:

  1. 接收 GCM/FCM 令牌

  2. 创建 NotificationHub 实例

  3. 使用 NotificationHub 实例和所需参数调用方法“registerTemplate”。

错误:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/net/http/AndroidHttpClient;
        at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:217)
        at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:178)
        at com.microsoft.windowsazure.messaging.Connection.executeRequest(Connection.java:134)
        at com.microsoft.windowsazure.messaging.NotificationHub.refreshRegistrationInformation(NotificationHub.java:296)
        at com.microsoft.windowsazure.messaging.NotificationHub.registerInternal(NotificationHub.java:390)
        at com.microsoft.windowsazure.messaging.NotificationHub.registerTemplate(NotificationHub.java:196)

【问题讨论】:

    标签: android azure azure-notificationhub


    【解决方案1】:

    将您的Android Support Library 更新到最新版本将解决此问题。除此之外,清理和重建项目以及重新启动 Android Studio 也会有所帮助。

    【讨论】:

    • 我正在使用最新版本的支持库和谷歌播放服务库。 SDK 使用 AndroidHttpClient 进行网络操作,此 API 在 Android 6 中已弃用,并在 Android 9 中完全删除。
    • 试试这个 android { useLibrary 'org.apache.http.legacy' } 在 build.gradle 中添加这个
    • 恐怕有什么解决办法。阅读这里developer.android.com/about/versions/pie/…
    【解决方案2】:

    目前在 Android Pie 中,httpclient 的引用已从系统 ClassLoader 中完全删除。如果我们将 httpclient 添加为应用程序 ClassLoader 的一部分,则可以解决上述问题。我已经添加了

    <uses-library android:name="org.apache.http.legacy" android:required="false" /> 
    

    在清单文件的应用程序标签内,它现在正在工作。 欲了解更多信息,请参阅以下链接: https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p

    【讨论】:

      【解决方案3】:

      此问题已在 0.5 版 Azure 通知中心 Android SDK 中得到修复。

      将您的 Azure 依赖项更新为:

      implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.5@aar'
      

      此版本使用HttpUrlConnection,而不是旧的HttpClient。查看拉取请求:https://github.com/Azure/azure-notificationhubs/pull/48

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-31
        • 2017-03-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多