AndroidPubSub Sample does not work!!! #308
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followed the instruction https://github.com/awslabs/aws-sdk-android-samples/tree/master/AndroidPubSub to set the parameter on the AWS cloud
Downloaded the whole code from https://github.com/awslabs/aws-sdk-android-samples
Used Android Studio 3.3.1 to open the folder AndroidPubSub
Changed the following part
PubSubActivity.java
// IoT endpoint
// AWS Iot CLI describe-endpoint call returns: XXXXXXXXXX.iot..amazonaws.com
private static final String CUSTOMER_SPECIFIC_ENDPOINT = "REPLACE_ME";
// Name of the AWS IoT policy to attach to a newly created certificate
private static final String AWS_IOT_POLICY_NAME = "REPLACE_ME";
awsconfiguration.json
"PoolId": "REPLACE_ME",
"Region": "Regions.US_EAST_1"
Sync, Build and Run App on emulator9.0 or Mobile Phone8.0, the result in Logcat is
com.amazonaws.demo.androidpubsub W/o.androidpubsu: Verification of com.amazonaws.logging.Log com.amazonaws.logging.LogFactory.getLog(java.lang.String) took 100.996ms
com.amazonaws.demo.androidpubsub E/com.amazonaws.demo.androidpubsub.PubSubActivity: onError:
java.lang.RuntimeException: Failed to initialize Cognito Identity; please check your awsconfiguration.json
at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:402)
at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalArgumentException: Failed to read CognitoIdentity please check your setup or awsconfiguration.json file
at com.amazonaws.auth.CognitoCredentialsProvider.getRegions(CognitoCredentialsProvider.java:195)
at com.amazonaws.auth.CognitoCredentialsProvider.(CognitoCredentialsProvider.java:174)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.(CognitoCachingCredentialsProvider.java:228)
at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:400)
at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalArgumentException: Cannot create enum from Regions.US_EAST_1 value!
at com.amazonaws.regions.Regions.fromName(Regions.java:114)
at com.amazonaws.auth.CognitoCredentialsProvider.getRegions(CognitoCredentialsProvider.java:193)
at com.amazonaws.auth.CognitoCredentialsProvider.(CognitoCredentialsProvider.java:174)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.(CognitoCachingCredentialsProvider.java:228)
at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:400)
at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
at java.lang.Thread.run(Thread.java:764)
Seems that the AWS modules do not work in the App.
How to deal with this problem?
Should there some other code be added?