My Android manifest uses different values when debugging and when releasing.
What's the easiest way to differentiate a value for each build type?
When debug:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my-lovely-debug-api-key" />
When release:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my-lovely-release-api-key" />
tia.
Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.
Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element. Note: You must include the QUERY_ALL_PACKAGES permission if your app targets Android 11 (API Level 30) or higher.
Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.
Note that if you are using default Eclipse builds it probably uses a specially configured 'Ant' module within eclipse. You can check on the degree of Eclipse/Ant coordination by checking 'Window/Preferences/Ant' section in eclipse/Prefs....
One solution is to make more explicit, the collaboration of Eclipse/Ant so that a 'build.xml' file is part of your project ( project level build file rather than the default file copied in at build time from the $SDK/ROOT folder ).
see here and read the comments at bottom here to get better idea of how a project level 'build.xml' file is used.
Once you've digested that , the solution below will make more sense...
--Solution--
Modify the Release and the Debug sections of you 'build.xml' file as follows:
<!-- **************** Debug specific targets *************** -->
...
<target name="-set-debug-mode" depends="-setup">
...
<!-- API modify belo for build-typ -->
<copy file="config/strings.xml" todir="res/values">
<filterset>
<filter token="CONFIG.API" value="${config.db.api}"/>
<filter token="CONFIG.REST" value="${config.db.rest}"/>
</filterset>
</copy>
...
<!-- *************** Release specific targets ************** -->
...
<target name="-set-release-mode" depends="-set-mode-check">
...
<!-- API modify belo for build-typ -->
<copy file="config/strings.xml" todir="res/values">
<filterset>
<filter token="CONFIG.API" value="${config.db.api.prod}"/>
<filter token="CONFIG.REST" value="${config.db.rest.prod}"/>
</filterset>
</copy>
And in the 'ant.properties' file in your root folder, put the property values for the API keys and whatever...
# API condition builds dev|prod in DB @parse.com
config.db.api=some_key_val
config.db.rest=some_k2_val
config.db.api.prod=some_k3_val
config.db.rest.prod=some_k4_val
And tie it together in a resource xml that is the target of the 'copy' commands in the build...
'config/strings.xml'
<string name="default_value_parse_key_appId">@CONFIG.API@</string>
<string name="default_value_parse_key_rest">@CONFIG.REST@</string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With