在这里构建paypal sdk时出错



我正试图将paypal 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不能得到我的位置,所以它没有访问它,但我有google play服务在我的gradle文件。这是我的android清单和构建。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的问题。

最新更新