I am using AWS Amplify and have two environments that I am switching between, therefore I have two awsconfiguration.json
files, but need a way to switch between the two at runtime. I've heard you can use sourceSets, but can't figure out how. I tried the following, but with no success. I believe I have to setup a productFlavor
and/or buildType
?
sourceSets {
prod {
res.srcDirs = ['res-prod']
}
dev {
res.srcDirs = ['res-dev']
}
}
Put your awsconfiguration.json
under assets
directory per each product flavor, see the directory structure as shown below:
For how to configure product flavor and build types, please refer to: https://developer.android.com/studio/build/build-variants for more details.
Then inside your code refer to your assets using code like below:
AssetManager am = context.getAssets();
InputStream is = am.open("awsconfiguration.json");
Reference: