yoomoney / yookassa-android-sdk

This library allows implementing payment acceptance into mobile apps on Android. It works as an extension to the YooMoney API.
https://yookassa.ru/developers/payment-forms/android-sdk
MIT License
40 stars 22 forks source link

Ошибка при запуске токенизации #32

Closed JulieSolnceva closed 4 years ago

JulieSolnceva commented 5 years ago

Здравствуйте! Я установила SDK Яндекс.Кассы для Android в своё приложение. Хочу получить токен. Написала код как в вашем примере.

private void openYandex(){ HashSet methodType = new HashSet(); methodType.add(PaymentMethodType.BANK_CARD); methodType.add(PaymentMethodType.SBERBANK);

        PaymentParameters paymentParameters = new PaymentParameters(
                new Amount(BigDecimal.TEN, Currency.getInstance("RUB")),
                "Название товара",
                "Описание товара",
                "Ключ моего приложения из личного кабинета Яндекс.Кассы",
                "Идентификатор магазина в Яндекс.Кассе",
                 methodType
        );

    TestParameters testParameters = new TestParameters(true, true, new MockConfiguration(false, true, 5));
    UiParameters uiParameters = new UiParameters(true, new ColorScheme(Color.rgb(0, 114, 245)));
       Intent intent = Checkout.createTokenizeIntent(this, paymentParameters, testParameters, uiParameters);
        startActivityForResult(intent, 1);
}

На строке "startActivityForResult(intent, 1);" на устройствах Digma и Samsung приложение падает с ошибкой :

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.xx.xx, PID: 13340
java.lang.NoSuchMethodError: ru.yandex.money.android.sdk.impl.f.a.b.requireContext at ru.yandex.money.android.sdk.impl.f.a.b.onCreateView(Unknown Source) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:753) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) at android.support.v4.app.Fragment.performStart(Fragment.java:2214) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1340) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:763) at ru.yandex.money.android.sdk.impl.CheckoutActivity.a(Unknown Source) at ru.yandex.money.android.sdk.impl.CheckoutActivity$a.invoke(Unknown Source) at ru.yandex.money.android.sdk.a.a$i.invoke(Unknown Source) at ru.yandex.money.android.sdk.impl.b.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5479) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method)

а на на устройствах Samsung добавляются ошибки: 08-07 13:27:53.011 787-1066/? E/Parcel: Class not found when unmarshalling: ru.yandex.money.android.sdk.PaymentParameters java.lang.ClassNotFoundException: ru.yandex.money.android.sdk.PaymentParameters at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:251) at java.lang.Class.forName(Class.java:216) at android.os.Parcel.readParcelableCreator(Parcel.java:2140) at android.os.Parcel.readParcelable(Parcel.java:2104) at android.os.Parcel.readValue(Parcel.java:2020) at android.os.Parcel.readArrayMapInternal(Parcel.java:2321) at android.os.Bundle.unparcel(Bundle.java:249) at android.os.Bundle.getString(Bundle.java:1118) at android.content.Intent.getStringExtra(Intent.java:5148) at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1470) at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1066) at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4075) at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3969) at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2650) at android.os.Binder.execTransact(Binder.java:404) at dalvik.system.NativeStart.run(Native Method) Caused by: java.lang.NoClassDefFoundError: ru/yandex/money/android/sdk/PaymentParameters at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:251)  at java.lang.Class.forName(Class.java:216)  at android.os.Parcel.readParcelableCreator(Parcel.java:2140)  at android.os.Parcel.readParcelable(Parcel.java:2104)  at android.os.Parcel.readValue(Parcel.java:2020)  at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)  at android.os.Bundle.unparcel(Bundle.java:249)  at android.os.Bundle.getString(Bundle.java:1118)  at android.content.Intent.getStringExtra(Intent.java:5148)  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1470)  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1066)  at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4075)  at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3969)  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2650)  at android.os.Binder.execTransact(Binder.java:404)  at dalvik.system.NativeStart.run(Native Method)  Caused by: java.lang.ClassNotFoundException: Didn't find class "ru.yandex.money.android.sdk.PaymentParameters" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:251)  at java.lang.Class.forName(Class.java:216)  at android.os.Parcel.readParcelableCreator(Parcel.java:2140)  at android.os.Parcel.readParcelable(Parcel.java:2104)  at android.os.Parcel.readValue(Parcel.java:2020)  at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)  at android.os.Bundle.unparcel(Bundle.java:249)  at android.os.Bundle.getString(Bundle.java:1118)  at android.content.Intent.getStringExtra(Intent.java:5148)  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1470)  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1066)  at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4075)  at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3969)  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2650)  at android.os.Binder.execTransact(Binder.java:404)  at dalvik.system.NativeStart.run(Native Method)  08-07 13:27:53.221 13340-13340/com.xxx.xxx E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

Как мне устранить эти ошибки?


код build.gradle:

apply plugin: 'com.android.application'

android { compileSdkVersion 26 buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.xxx.xxx"
    minSdkVersion 16
    targetSdkVersion 26
    ndk {
        moduleName "modul1"
    }
    manifestPlaceholders = [YANDEX_CLIENT_ID:"xxxxx"]
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

flavorDimensions "version"
productFlavors {
    flavor1 {
        dimension "version"
        applicationId "com.xxx.xxx"
        versionName "4.0.0"
        versionCode 402
    }    
}

testOptions {
    unitTests.returnDefaultValues = true
}

}

repositories { mavenCentral() maven { url 'https://dl.bintray.com/yandex-money/maven' } } dependencies {

implementation 'com.yandex.money:checkout:2.3.0'
implementation 'com.yandex.android:authsdk:2.0.0'

implementation project(':docview')
implementation files('src/main/jniLibs/edm.jar')
implementation files('src/main/jniLibs/license.jar')

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.github.woxthebox:draglistview:1.2.1'
implementation 'org.scilab.forge:jlatexmath:1.0.2'
implementation 'com.caverock:androidsvg:1.2.2-beta-1'
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.0.0'
implementation 'org.kamranzafar:jtar:2.3'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.android.support:appcompat-v7:26.2.1'
implementation 'com.android.support:design:26.2.1'
implementation 'com.android.support:recyclerview-v7:26.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.android.gms:play-services-appindexing:8.4.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
testImplementation 'junit:junit:4.12'
testImplementation 'org.json:json:20140107'

}

configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '25.3.0' } } } }


drukarev commented 5 years ago

Добрый день. Можно попробовать несколько вещей: 1) Поднять targetSdkVersion и compileSdkVersion до 28 (это в любом случае нужно сделать, поскольку с августа это обязательно для выкладки в Google Play - https://developer.android.com/distribute/best-practices/develop/target-sdk) 2) Включить r8 и Jetifier Если это не помогло, то пришлите, пожалуйста, пустое приложение с настройками, где воспроизводится проблема, на b2b-app-support@yamoney.ru