How do I build two android app versiosn with different API endpoints without editing code every time?

StackOverflow https://stackoverflow.com/questions/22386375

문제

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.

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

도움이 되었습니까?

해결책

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.

 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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top