AWS CloudWatch Log on Android

The name of the picture


AWS CloudWatch Log on Android



I'm trying to use AWS CloudWatch Log in an Android app.
I have the following config for the 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()



In the build.gradle I have


implementation ("com.amazonaws:aws-java-sdk-logs:1.11.367") {
exclude module: 'joda-time'
}



The app is crashing at awsLogsClientBuilder.build() with the following exception:


awsLogsClientBuilder.build()



E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxxxxx.xxxxx, PID: 28703
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes2.dex)...



I have tried to use the android specific library as well:


androidSdkLogsVersion = "2.6.24"
implementation "com.amazonaws:aws-android-sdk-logs:$androidSdkLogsVersion"



and/or


implementation "com.amazonaws:aws-android-sdk-mobile-client:$androidSdkLogsVersion"



but if I use it along with the java sdk I get an error at compile time:



Program type already present: com.amazonaws.ResponseMetadata



If I do not import the java-sdk then I get an error at compile time because the class AWSLogsClientBuilder is not found anymore.


AWSLogsClientBuilder



How should I create the logger on Android?




1 Answer
1



This is what I did:



In the build.gradle


androidSdkLogsVersion = "2.6.24"
implementation "com.amazonaws:aws-android-sdk-logs:$androidSdkLogsVersion"



and to configure the logger:


val basicAWSCredentials = BasicAWSCredentials("xxxxx","yyyy")
val awsClient = AmazonCloudWatchLogsClient(basicAWSCredentials)
val regions: Regions = Regions.EU_WEST_1
awsClient.setRegion(Region.getRegion(regions.getName()))






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to scale/resize CVPixelBufferRef in objective C, iOS

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

SVG with two text elements. When one resizes due to textLength - how to resize the other one to the same character size