如何构建两个具有不同API端点的Android应用程序versiosn而不必每次都编辑代码?

时间:2022-05-23 11:32:29

I have a staging server and prod server at work. I want to build a staging app version and prod app version by changing a build target choice in Eclipse or similar.

我有一个登台服务器和prod服务器在工作。我想通过在Eclipse或类似版本中更改构建目标选项来构建临时应用程序版本和prod应用程序版本。

How do people do that? Ive searched and learned that it is not part of Eclipse like it is for XCode.

人们如何做到这一点?我搜索并了解到它不像Eclipse那样是XCode的一部分。

1 个解决方案

#1


2  

I use Gradle & Android studio. You can define Debug & release level constants in the gradle file, which then get turned into java source files, which are then compiled are required. Very nifty.

我使用Gradle和Android工作室。您可以在gradle文件中定义调试和发布级别常量,然后将其转换为java源文件,然后编译这些文件是必需的。非常漂亮。

 buildTypes {
        debug {
            buildConfig "public final static String URL = "http://www.test.com;"
        }
        release {
            buildConfig "public final static String URL = "http://www.live.com;"
        }
    }

probably not exactly what you were hoping for but maybe this can help convince you or your lead or your boss,etc to switch :)

可能不完全是你所希望的,但也许这可以帮助说服你或你的领导或你的老板等切换:)

#1


2  

I use Gradle & Android studio. You can define Debug & release level constants in the gradle file, which then get turned into java source files, which are then compiled are required. Very nifty.

我使用Gradle和Android工作室。您可以在gradle文件中定义调试和发布级别常量,然后将其转换为java源文件,然后编译这些文件是必需的。非常漂亮。

 buildTypes {
        debug {
            buildConfig "public final static String URL = "http://www.test.com;"
        }
        release {
            buildConfig "public final static String URL = "http://www.live.com;"
        }
    }

probably not exactly what you were hoping for but maybe this can help convince you or your lead or your boss,etc to switch :)

可能不完全是你所希望的,但也许这可以帮助说服你或你的领导或你的老板等切换:)