Я пытаюсь реализовать библиотеку обработки платежей под названием Openpay в моем приложении, но я получаю сообщение об ошибке android API 23. Всякий раз, когда я пытаюсь инициализировать их объект API следующим образом
OpenpayAPI api = new OpenpayAPI("https://sandbox-api.openpay.mx", privateKey, merchantId);
Я получаю ошибку в заголовке:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.deepdatatechnologies.uprmachine, PID: 11114
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicLineFormatter; in class Lorg/apache/http/message/BasicLineFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicLineFormatter' appears in /system/framework/org.apache.http.legacy.boot.jar)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)
at mx.openpay.client.core.impl.DefaultHttpServiceClient.initHttpClient(DefaultHttpServiceClient.java:133)
at mx.openpay.client.core.impl.DefaultHttpServiceClient.<init>(DefaultHttpServiceClient.java:90)
at mx.openpay.client.core.JsonServiceClient.<init>(JsonServiceClient.java:59)
at mx.openpay.client.core.OpenpayAPI.<init>(OpenpayAPI.java:80)
at com.deepdatatechnologies.uprmachine.MainOperatorBankActivity.<init>(MainOperatorBankActivity.java:22)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/System: Uncaught exception thrown by finalizer
java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.http.impl.conn.CPool.shutdown()' on a null object reference
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:347)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.finalize(PoolingHttpClientConnectionManager.java:168)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:202)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)
at java.lang.Thread.run(Thread.java:818)
I/Process: Sending signal. PID: 11114 SIG: 9
Process 11114 terminated.
Я пытался добавить useLibrary 'org.apache.http.legacy'
, как люди в других сообщениях сказали, но это не сработало Я получаю ту же ошибку. Вот мой полный файл Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.deepdatatechnologies.uprmachine"
minSdkVersion 23
targetSdkVersion 29
useLibrary 'org.apache.http.legacy'
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:support-v4:+'
implementation 'com.android.support:appcompat-v7:+'
//facebook
implementation 'com.facebook.android:facebook-login:[5,6)'
//google
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.shobhitpuri.custombuttons:google-signin:1.1.0'
//osm
implementation 'org.osmdroid:osmdroid-android:6.1.5'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//openpay
implementation 'mx.openpay:openpay-api-client:1.0.16'
implementation files('libs\\openpay-v2.0.3.aar')
implementation project(path: ':openpay-v2.0.3')
implementation 'com.google.http-client:google-http-client:1.28.0'
implementation 'com.google.http-client:google-http-client-android:1.28.0'
implementation 'com.google.http-client:google-http-client-jackson2:1.28.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//glide dependencies
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
//circleImageView
implementation 'de.hdodenhof:circleimageview:3.1.0'
}
Любая помощь будет принята с благодарностью