Search code examples
androidvisual-studio-2012releasevs-android

Building release Android APK with vs-android


I have a large amount of C++ native code and a small wrapping java code for Android application. I was able to combine them into an Android app using vs-android and build it directly from Visual Studio 2012. But I can do this only in DEBUG mode. In RELEASE - ant complains that I need a key to sign the app. What do I need to do in order to be able to build RELEASE app and deploy it to device automatically (as done in DEBUG mode)?

By the way, I want to build a RELEASE just to see how fast the C++ code runs and not for publishing the application on Google store. So If there is a way to inject the key which is used in DEBUG mode also for RELEASE that would be great.

A solution I don't want to receive: Run a build that creates un-signed APK, and than call a batch file that adds signature, zipalligns, etc... I want everything to run smoothly when hitting the 'build' button in Visual Studio.

Another bad solution is using Ecllipse. I want to use visual studio.

Please help


Solution

  • I have found the solution:

    1. Go to the directory of ANT build.xml inside Android SDK. Mine was here: C:\android_sdk\adt-bundle-windows-x86_64-20130514\sdk\tools\ant The build.xml file is rather large (about 70kb). Open this file for editing.
    2. Find the line <target name="-release-nosign" unless="has.keystore">
    3. Add the following properties bellow:

    <property name="has.keystore" value="true" />

    <property name="key.store" value="release.keystore" />

    <property name="key.store.password" value="android" />

    <property name="key.alias" value="androiddebugkey" />

    <property name="key.alias.password" value="android" />

    1. Finaly, go to the directory of the APK you are trying to compile, You should already have debug.keystore file. Just copy it and rename it release.keystore