我试图在这里将paypal添加到我的应用程序中。他们的示例应用程序没有问题。所以我用它作为一个例子,构建了一个中间层服务器,让我的应用程序从它请求令牌。现在的问题是,当我尝试初始化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清单和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')
}
答案 0 :(得分:2)
问题来自您的应用所依赖的库之一,库也依赖于Google Play Services
。解决方案是查看您使用的库是否具有8.1.0
的新更新版本,或者尽可能删除该依赖项。有关详细信息,请参阅here。
此外,您可以尝试将其降级到较旧的播放服务版本,并且它可以正常工作。这是应用程序与Google Play Service 8.1.0
不兼容的问题。