Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidPubSub Sample does not work!!! #719

Closed
frankmuellr opened this issue Feb 22, 2019 · 7 comments
Closed

AndroidPubSub Sample does not work!!! #719

frankmuellr opened this issue Feb 22, 2019 · 7 comments
Assignees
Labels
iot Issues with the AWS Android SDK for Internet of Things (IoT) pending-community-response Issue is pending response from the issue requestor question General question

Comments

@frankmuellr
Copy link

frankmuellr commented Feb 22, 2019

This issue was originally opened by @iwwork as a PR in the sample app repo:
awslabs/aws-sdk-android-samples#308

Which AWS Services are you utilizing?
AWS IoT

Provide code snippets (if applicable)
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?

Environment(please complete the following information):

  • SDK Version: [e.g. 2.6.25]

Device Information (please complete the following information):

  • Device: [e.g. Pixel XL, Simulator]
  • Android Version: [e.g. Nougat 7.1.2]
  • Specific to simulators:

If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.

@frankmuellr frankmuellr added question General question iot Issues with the AWS Android SDK for Internet of Things (IoT) labels Feb 22, 2019
@iwwork
Copy link

iwwork commented Feb 25, 2019

@muellerfr Hi Muelle, thanks for your kind help. Could you give some constructive suggestion?

@desokroshan
Copy link
Contributor

@iwwork Thanks for submitting the issue. Apologies for the inconvenience. I will try to reproduce the issue and get back to you soon.

@minbi
Copy link
Contributor

minbi commented Feb 25, 2019

Hi @iwwork ,

awsconfiguration.json
"PoolId": "REPLACE_ME",
"Region": "Regions.US_EAST_1"

If you have Regions.US_EAST_1 as the region value, please replace it with us-east-1 instead.

@frankmuellr frankmuellr added the pending-community-response Issue is pending response from the issue requestor label Feb 25, 2019
@iwwork
Copy link

iwwork commented Feb 26, 2019

@minbi this does not work.

@minbi
Copy link
Contributor

minbi commented Feb 26, 2019

Can you elaborate or potentially provide a stacktrace?

@desokroshan
Copy link
Contributor

Sounds like this issue has been resolved as mentioned in #750. Closing this issue.

@XCarbone
Copy link

XCarbone commented Apr 2, 2020

Hi @iwwork ,

awsconfiguration.json
"PoolId": "REPLACE_ME",
"Region": "Regions.US_EAST_1"

If you have Regions.US_EAST_1 as the region value, please replace it with us-east-1 instead.

this work just write the region in lowercase with - instade of _ and Caused by: java.lang.IllegalArgumentException: Failed to read CognitoIdentity please check your setup or awsconfiguration.json file will be initialise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iot Issues with the AWS Android SDK for Internet of Things (IoT) pending-community-response Issue is pending response from the issue requestor question General question
Projects
None yet
Development

No branches or pull requests

5 participants