das*_*rus 4 android amazon-web-services android-studio aws-amplify
我正在使用 AWS 和 Android Studio 为大学制作 Android 应用程序。我一直试图通过https://docs.amplify.aws/start/q/integration/android弄清楚它是如何工作的,但我似乎无法让它在最后一部分中工作,即将其连接到云端。当我运行该应用程序时,我总是收到以下错误:
\n AmplifyException {message=Failed to parse configuration JSON for AWS API Plugin, cause=AmplifyException {message=Failed to parse configuration, missing required key: endpoint, cause=null, recoverySuggestion=Sorry, we don\'t have a suggested fix for this error yet.}, recoverySuggestion=Check amplifyconfiguration.json to make sure the AWS API configuration section hasn\'t been wrongly modified.}\n at com.amplifyframework.api.aws.AWSApiPluginConfigurationReader.parseConfigurationJson(AWSApiPluginConfigurationReader.java:97)\n at com.amplifyframework.api.aws.AWSApiPluginConfigurationReader.readFrom(AWSApiPluginConfigurationReader.java:56)\n at com.amplifyframework.api.aws.AWSApiPlugin.configure(AWSApiPlugin.java:127)\n at com.amplifyframework.core.category.Category.configure(Category.java:86)\n at com.amplifyframework.core.Amplify.configure(Amplify.java:153)\n at com.amplifyframework.core.Amplify.configure(Amplify.java:120)\n at com.example.todo.MyAmplifyApplication.onCreate(MyAmplifyApplication.java:18)\n at android.app.Instrumentation.callApplicationOnCreate(Unknown Source:0)\n at android.app.ActivityThread.handleBindApplication(Unknown Source:1209)\n at android.app.ActivityThread.access$1400(Unknown Source:0)\n at android.app.ActivityThread$H.handleMessage(Unknown Source:710)\n at android.os.Handler.dispatchMessage(Unknown Source:19)\n at android.os.Looper.loop(Unknown Source:242)\n at android.app.ActivityThread.main(Unknown Source:98)\n at java.lang.reflect.Method.invoke(Native Method)\n at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)\n at com.android.internal.os.ZygoteInit.main(Unknown Source:275)\n Caused by: AmplifyException {message=Failed to parse configuration, missing required key: endpoint, cause=null, recoverySuggestion=Sorry, we don\'t have a suggested fix for this error yet.}\n at com.amplifyframework.api.aws.AWSApiPluginConfigurationReader.parseConfigurationJson(AWSApiPluginConfigurationReader.java:72)\n at com.amplifyframework.api.aws.AWSApiPluginConfigurationReader.readFrom(AWSApiPluginConfigurationReader.java:56)\xc2\xa0\n at com.amplifyframework.api.aws.AWSApiPlugin.configure(AWSApiPlugin.java:127)\xc2\xa0\n at com.amplifyframework.core.category.Category.configure(Category.java:86)\xc2\xa0\n at com.amplifyframework.core.Amplify.configure(Amplify.java:153)\xc2\xa0\n at com.amplifyframework.core.Amplify.configure(Amplify.java:120)\xc2\xa0\n at com.example.todo.MyAmplifyApplication.onCreate(MyAmplifyApplication.java:18)\xc2\xa0\n at android.app.Instrumentation.callApplicationOnCreate(Unknown Source:0)\xc2\xa0\n at android.app.ActivityThread.handleBindApplication(Unknown Source:1209)\xc2\xa0\n at android.app.ActivityThread.access$1400(Unknown Source:0)\xc2\xa0\n at android.app.ActivityThread$H.handleMessage(Unknown Source:710)\xc2\xa0\n at android.os.Handler.dispatchMessage(Unknown Source:19)\xc2\xa0\n at android.os.Looper.loop(Unknown Source:242)\xc2\xa0\n at android.app.ActivityThread.main(Unknown Source:98)\xc2\xa0\n at java.lang.reflect.Method.invoke(Native Method)\xc2\xa0\n at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)\xc2\xa0\n at com.android.internal.os.ZygoteInit.main(Unknown Source:275)\nRun Code Online (Sandbox Code Playgroud)\n我完全按照教程中的步骤进行操作,但我总是卡在这里。这就是我所做的:
\n到目前为止,该应用程序仍然运行良好。总是在下一步失败,那就是添加:
\nAmplify.DataStore.observe(Todo.class,\n started -> Log.i("Tutorial", "Observation began."),\n change -> Log.i("Tutorial", change.item().toString()),\n failure -> Log.e("Tutorial", "Observation failed.", failure),\n () -> Log.i("Tutorial", "Observation complete.")\n);\nRun Code Online (Sandbox Code Playgroud)\n我已经尝试并制作了一个全新的项目,并确保再次遵循这些步骤,但无济于事。我不确定它是否相关,但我也通过 AWS Educate 使用 AWS,因此没有那么多资源展示如何使用我的有限帐户使用 AWS 服务。有人可以帮忙吗?我完全陷入困境,我什至不知道出了什么问题。任何帮助表示赞赏,谢谢!
\nAmplify Android 库在运行时加载配置文件。该文件必须存在于您的应用程序项目中,位于app/src/main/res/raw/amplifyconfiguration.json. 当您设置 Android DataStore 时,此文件会自动包含在您的项目中。
无法解析配置,缺少必需的密钥:端点
此消息表明您amplifyconfiguration.json存在,但不包含 DataStore 将与之通信的 AppSync 端点的合适配置。
您的amplifyconfiguration.json内容应该如下所示(如果您使用 API 密钥身份验证):
{
"userAgent": "aws-amplify-cli/2.0",
"version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"VARIES_DEPENDING_ON_YOUR_CLI_SESSION": {
"endpointType": "GraphQL",
"endpoint": "https:/UNIQUE_TO_YOUR_ENDPOINT.appsync-api.us-west-2.amazonaws.com/graphql",
"region": "us-west-2",
"authorizationType": "API_KEY",
"apiKey": "da2-UNIQUE_TO_YOUR_API_KEY"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
例如,如果您没有运行amplify add api和,则可能会发生此错误amplify push。在这种情况下,您可能有一个几乎空的配置文件:
{
"userAgent": "aws-amplify-cli/2.0",
"version": "1.0",
}
Run Code Online (Sandbox Code Playgroud)
我认为端点设置并不像 Amplify 文档中应有的那样清晰。感谢您在 Amplify 文档项目中提交此 GitHub 问题。我们将努力改进文档。
注意:我是 AWS Amplify Android 的维护者。
| 归档时间: |
|
| 查看次数: |
5641 次 |
| 最近记录: |