我正在尝试在 Android 应用程序中使用 AWS CloudWatch Log。
我对 aws-client 有以下配置:
val basicAWSCredentials = BasicAWSCredentials(
“Xxxxxx”,
“Yyyyyy”
)
val awsLogsClientBuilder = AWSLogsClientBuilder.standard()
awsLogsClientBuilder.region = Regions.EU_WEST_2.name
awsLogsClientBuilder.credentials = AWSStaticCredentialsProvider(basicAWSCredentials)
awsClient = awsLogsClientBuilder.build()
在 build.gradle 我有
implementation ("com.amazonaws:aws-java-sdk-logs:1.11.367") {
exclude module: 'joda-time'
}
该应用程序崩溃于awsLogsClientBuilder.build()
但以下情况除外:
E/AndroidRuntime:致命异常:main
进程:com.xxxxxx.xxxxx,PID:28703
java.lang.NoSuchFieldError:没有 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的静态字段实例;在类 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 中;或其超类(“org.apache.http.conn.ssl.AllowAllHostnameVerifier”的声明出现在 /system/framework/framework.jar!classes2.dex 中)...
我也尝试过使用 android 特定的库:
androidSdkLogsVersion = "2.6.24"
implementation "com.amazonaws:aws-android-sdk-logs:$androidSdkLogsVersion"
and/or
implementation "com.amazonaws:aws-android-sdk-mobile-client:$androidSdkLogsVersion"
但如果我将它与 java sdk 一起使用,我会在编译时收到错误:
程序类型已存在:com.amazonaws.ResponseMetadata
如果我不导入 java-sdk 那么我会在编译时收到错误,因为该类AWSLogsClientBuilder
已经找不到了。
我应该如何在 Android 上创建记录器?