Solution 1 :
I figured it out!
The Amplify.configure()
has a not-well-documented overload where you can specify a config file in the form of an Android “resource.”
So instead of using
Amplify.configure(getApplicationContext());
as directed in the tutorials, I use
Amplify.configure(
AmplifyConfiguration.fromConfigFile(getApplicationContext(), R.raw.amplifyconfiguration),
getApplicationContext());
The config file needs to be located in the app/src/main/res/raw/
path of the project, named amplifyconfiguration.json
. The development environment automatically generates the definition of the value R.raw.amplifyconfiguration
, which is a number identifying the file.
That solves the problem of loading the configuration from an explicit file, without using the amplify CLI. The next hurdle is figuring out what keys can be specified in the file…
Problem :
I’m trying to write an application that uses the AWS API from an Android app written in Java. It seems that the recommended way to do it is using a special set of libraries called “Amplify.” I was able to import the appropriate Amplify Java classes into my code, but I see that not all the parameters I want to supply (such as the S3 bucket or the API access key) can be given as method arguments.
All the advice I see online suggests running a command-line configuration command using npm install aws-amplify
. But I’d prefer not to use a command-line tool which asks me questions: I’d prefer to configure everything in code. And I don’t want to install npm or mess around with it (full disclosure, I tried installing it and got some hassles).
Is there a way to supply the Amplify configuration without using the command-line tool, perhaps via a configuration file or some additional arguments to the methods I’m calling within Java?
Comments
Comment posted by barrelmaker
Indeed, and how do I configure it?
Comment posted by stackoverflow.com/questions/61281838/…
The amplify resources are configured using the Amplify CLI, which for each resource generates its own cloudformation templates. The same question was asked for IOS application. There is some hacks. But the clean solution is to use the CLI.
Comment posted by docs.amplify.aws/lib/auth/existing-resources/q/platform/android
These links can help someone who is still looking for what to put inside the configuration file: Auth: