Exception java.lang.NoSuchMethodError: decodeBase64 in Android devices with API < 28
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Bắt đầu với com.google.api.client.util.Base64.java và PemReader, nơi stack trace đi đến lệnh gọi decodeBase64 không tương thích, sau đó kiểm tra cách dependency Apache Commons Codec được phân giải cho Android. Tái hiện với mẫu speech của Android trên một API thấp hơn 28 và xác minh rằng việc tải thông tin xác thực không còn ném NoSuchMethodError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
We have found that the library is throwing an exception in any Android device with and API < 28 (Android 9.0) after version com.google.cloud:google-cloud-speech:0.70.0-beta. The problem is related with this issue. As far as we know, Apache common codec library dependency version is 1.10 in this project, but Android in versions below 9.0 has the same classes in boot classpath, so classes from the version 1.10 will never be loaded. This issue will not be solved in Android, thus we would like to ask for a solution here, removing/replacing the dependency in some way.
Thanks in advance.
Please include as much information as possible:
Environment details
- OS: Android API < 28
- Java version:1.8
- google-cloud-java version(s): from 0.71.0-beta
Steps to reproduce
1. Zip file attached or get Android speech example source code from:
https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/SpeechRecognitionClient
2. Import app into Android Studio.
3. Modify build-gradle (module app) file to update dependencies in
section dependencies:
// add these dependencies for the speech client
implementation 'io.grpc:grpc-okhttp:1.18.0'
implementation 'com.google.cloud:google-cloud-speech:0.71.0-beta'
4. Build app with Android Studio and run in development mode on Android device below API 28.
Stacktrace
2019-02-21 10:56:28.171 12310-12310/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.cloud.examples.speechrecognition, PID: 12310
java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
at com.google.api.client.util.Base64.decodeBase64(Base64.java:101)
at com.google.api.client.util.PemReader.readNextSection(PemReader.java:106)
at com.google.api.client.util.PemReader.readFirstSectionAndClose(PemReader.java:135)
at com.google.auth.oauth2.ServiceAccountCredentials.privateKeyFromPkcs8(ServiceAccountCredentials.java:290)
at com.google.auth.oauth2.ServiceAccountCredentials.fromPkcs8(ServiceAccountCredentials.java:280)
at com.google.auth.oauth2.ServiceAccountCredentials.fromJson(ServiceAccountCredentials.java:210)
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:174)
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:141)
at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2$1$1.getCredentials(MainActivity.kt:69)
at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2$1$1.getCredentials(MainActivity.kt:47)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:132)
at com.google.cloud.speech.v1.stub.GrpcSpeechStub.create(GrpcSpeechStub.java:94)
at com.google.cloud.speech.v1.stub.SpeechStubSettings.createStub(SpeechStubSettings.java:126)
at com.google.cloud.speech.v1.SpeechClient.<init>(SpeechClient.java:144)
at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:126)
at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2.invoke(MainActivity.kt:68)
at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2.invoke(MainActivity.kt:47)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.google.cloud.examples.speechrecognition.MainActivity.getMSpeechClient(MainActivity.kt)
at com.google.cloud.examples.speechrecognition.MainActivity.onResume(MainActivity.kt:105)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
at android.app.Activity.performResume(Activity.java:6830)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3407)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3470)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Code snippet
private val mSpeechClient by lazy {
// NOTE: The line below uses an embedded credential (res/raw/sa.json).
// You should not package a credential with real application.
// Instead, you should get a credential securely from a server.
applicationContext.resources.openRawResource(R.raw.google_cloud_credentials).use {
SpeechClient.create(SpeechSettings.newBuilder()
.setCredentialsProvider { GoogleCredentials.fromStream(it) }
.build())
}
}
Any additional information below
Thanks!
- Ngôn ngữ chính
- Java
- Star
- 1.4k
- Fork
- 476
- Merge trung bình
- 10 giờ 47 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-http-java-client
-
Core: Validate header names and values to prevent CRLF injectionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()Có thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeExceptionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
org.apache.http.conn.ssl.SSLSocketFactory is deprecatedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởpriority: p2 type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Tất cả issue của googleapis/google-http-java-client
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 84/100
cpp-best-practices/project_validator#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend enhancement
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changeCó thể đã có người làm @dwizard0 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày