在这里构建paypal sdk时出错
error while building paypal here sdk
我正在尝试将 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 播放服务。这是我的 android 清单和 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
的新更新版本,或者如果可能的话删除该依赖项。详情请参考.
此外,您可以尝试实际降级到较旧的播放服务版本,它工作得很好。这是应用程序与 Google Play Service 8.1.0
不兼容的问题。
我正在尝试将 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 播放服务。这是我的 android 清单和 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
的新更新版本,或者如果可能的话删除该依赖项。详情请参考
此外,您可以尝试实际降级到较旧的播放服务版本,它工作得很好。这是应用程序与 Google Play Service 8.1.0
不兼容的问题。