简体   繁体   English

我可以为Android应用的alpha / beta / prod环境提供不同的资源吗?

[英]Can I provide different resources to alpha/beta/prod enviroment of an Android app?

I have an android app, which communicates to a server through HTTP requests. 我有一个Android应用程序,可通过HTTP请求与服务器通信。 The server's address is defined in an XML resource file, under the folder res/values. 服务器的地址在XML资源文件的res / values文件夹下定义。 There is a tag with the type="config" for it. 有一个带有类型=“ config”的标签。 I have different addresses for the server, based on its environment. 根据服务器的环境,我对服务器有不同的地址。 For example, there is a server for tests under the xxxx address, while there is a production server under the yyyy address. 例如,在xxxx地址下有一个用于测试的服务器,而在yyyy地址下有一个生产服务器。

On the developers console, I uploaded an apk for the beta users, linked to the tests server. 在开发人员控制台上,我为beta用户上传了一个与测试服务器链接的apk。 I would like to promote it to production, but I would need to generate a new apk file only with the update changing the server's URL. 我想将其推广到生产环境,但是我只需要通过更改服务器URL的更新来生成一个新的apk文件。

Q: can I provide different resources for alpha, beta and production environments, without the need of a new apk release? 问:我可以在不需要新的APK版本的情况下为alpha,beta和生产环境提供不同的资源吗?

Would it be possible to add some /res/values-beta/ folder, eg? 例如,是否可以添加一些/ res / values-beta /文件夹? Alternatively, is there a programmatic way to check in which environment the app is? 另外,是否可以通过编程方式检查应用程序在哪个环境中? This way I could myself decide which config to take. 这样,我自己可以决定采用哪种配置。

As mentioned in the comments, you need to use build variants and build flavors. 如评论中所述,您需要使用构建变体和构建风味。 Here's a great tutorial on how to do it: 这是有关如何执行此操作的出色教程:

http://blog.robustastudio.com/mobile-development/android/building-multiple-editions-of-android-app-gradle/ http://blog.robustastudio.com/mobile-development/android/building-multiple-editions-of-android-app-gradle/

Hi I was also Searching for the same from past so many days and I came to this tutorial: 嗨,我也在过去几天搜索相同的内容,因此来到了本教程:

https://medium.com/@rdsubhas/a-better-android-release-pipeline-7eca6d76f0da#.nwfl59qs0 https://medium.com/@rdsubhas/a-better-android-release-pipeline-7eca6d76f0da#.nwfl59qs0

This is using productFlavors to have different end points for alpha/Beta And Production apk wihtout having to upload the new apk. 这使用productFlavors为Alpha / Beta和Production apk设置了不同的端点,而不必上传新的apk。

Hope this help you. 希望这对您有所帮助。

If you have already find your solution then do share it here. 如果您已经找到解决方案,请在此处共享。

Thanks.. 谢谢..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM