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

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

Frage

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.

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top