1

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

DanielHsH
  • 4,287
  • 3
  • 30
  • 36
  • 1
    I believe only Eclipse and Android Studio are the official tools. So, it can happen that your desire remains unsatisfied. Although maybe someone does use VS. What's so special about VS? – Alexander Kulyakhtin Jun 11 '13 at 13:09
  • Have you considered just replacing your debug keystore with a release key (sans password)? – 323go Jun 11 '13 at 13:13
  • Impossible. There is no debug keystore of "mine" since ant does that. It is created during the build. I know that the solution to this problem should be easy but I don't know it. P.s. - The special thing in VS-android is that I can build android apps from visual studio – DanielHsH Jun 11 '13 at 17:21
  • 1
    Whoever down voted my question, please explain, why. This is a valid question and my Answer is also valid. – DanielHsH Jun 17 '13 at 07:25

2 Answers2

3

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
DanielHsH
  • 4,287
  • 3
  • 30
  • 36
1

Run keytool and create a keystore, for example

C:\my-project\my-release-keystore.keystore

then in the same directory as your project.properties add an ant.properties with the following:

key.store=C:\\my-project\\my-release-keytore.keystore
key.store.password=my-keystore-password
key.alias=my-apps-alias
key.alias.password=my-alias-password

That's it - when you build release mode ANT will sign your release APK.

rpax
  • 4,468
  • 7
  • 33
  • 57