【发布时间】:2023-03-20 17:23:01
【问题描述】:
我正在尝试将 paypal here sdk 添加到我的应用程序中。他们的示例应用程序没有问题。所以我以它为例,构建了一个中间层服务器,并让我的应用程序从中请求令牌。现在的问题是当我尝试初始化 SDK 时出现以下错误
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: com.bistrobot.bistrobot, PID: 17506
E/AndroidRuntime: java.lang.IncompatibleClassChangeError: The method 'boolean com.google.android.gms.common.api.GoogleApiClient.isConnected()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
E/AndroidRuntime: at com.paypal.merchant.sdk.internal.service.GooglePlayLocationServiceImpl.startLocationService(GooglePlayLocationServiceImpl.java:48)
E/AndroidRuntime: at com.paypal.merchant.sdk.internal.SDKCore.init(SDKCore.java:166)
E/AndroidRuntime: at com.paypal.merchant.sdk.PayPalHereSDK.init(PayPalHereSDK.java:163)
E/AndroidRuntime: at com.bistrobot.bistrobot.sdk.PayPalHereSDKWrapper.initializeSDK(PayPalHereSDKWrapper.java:65)
E/AndroidRuntime: at com.bistrobot.bistrobot.login.LoginActivity.startPaymentOptionsActivity(LoginActivity.java:91)
E/AndroidRuntime: at com.bistrobot.bistrobot.login.LoginActivity.onCreate(LoginActivity.java:42)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6374)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
基于错误,我认为 sdk 无法获取我的位置,因此无法访问它,但我的 gradle 文件中有 google play 服务。这是我的 android manifest 和 build.gradle,以防万一有人指出正确的方向。仅供参考,sdk 作为模块添加,因此它不显示附加的构建 gradle。
清单
<uses-feature android:name="android.hardware.usb.host" />
<supports-screens android:xlargeScreens="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@drawable/icon_transparent"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".login.LoginActivity"
android:label="@string/app_name"
android:noHistory="true"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".login.DeviceListActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden|adjustPan|adjustResize">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<action android:name="android.hardware.usb.action.USB_DEVICE_DEATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
<activity
android:name=".ui.MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="landscape" />
</application>
Build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.bistrobot.bistrobot"
minSdkVersion 21
targetSdkVersion 23
versionCode 3
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile project(':usbSerialForAndroid')
compile project(':PayPalHereSDK')
}
【问题讨论】:
-
问题来自您的应用所依赖的库之一,该库本身也依赖于
Google Play Services。解决方案是查看您使用的库是否也有带有8.1.0的新更新版本,或者如果可能,删除该依赖项。更多详情请参考here。 -
我最终实际上降级到了一个较旧的播放服务版本,它工作得很好。这是该应用程序与 Google Play Service 8.1.0 不兼容的问题。所以你是绝对正确的。谢谢
-
很高兴为您提供帮助,干杯!
标签: android google-play-services paypal-sandbox paypal-rest-sdk paypal