How can I separate my firebase prod and dev storage with buildtypes or flavors in android ?
I already know how to separate the database but this doesn't apply to storage.
The problem is that the code to instantiate the storage doesn't rely on google-services.json but on a fixed url :
FirebaseStorage.getInstance().getReferenceFromUrl("gs://dev-app.appspot.com");
buildTypes { debug { buildConfigField "String", "BASE_URL", '"gs://dev-app.appspot.com"' } release { buildConfigField "String", "BASE_URL", '"gs://prod-app.appspot.com"' }
In your code use
FirebaseStorage.getInstance().getReferenceFromUrl(BuildConfig.BASE_URL);
The accepted answer is not the most robust way to separate your builds. I have written a more comprehensive set of solutions in this blog post on the Firebase Blog . Changing the default storage bucket is just like changing the default Database URL when dealing with google-services.json - you don't need to bake the constant value of the bucket URL into your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.