I'm trying to test in-app billing in my app. I have billing and product id's all setup in the Play store but to test a transaction I need to sign my app with my release keystore otherwise it fails.
I'm using IntelliJ Idea (Ver. 11 CE) and can't quite figure out how to configure the project to build with debug set and sign with my release keystore before deploying to my device.
I see I can set an ant target for a configuration and I'm assuming that's the way to go but since my build.xml imports the Android SDK /tools/ant/build.xml there aren't any targets in to choose.
To debug do I merely need to enable set android:debuggable="true" in the manifest? Anyone have a suggestion for an ant target that would do the things I need? One that I can add to my build.xml?
With pointers in the right direction form Ixx I ended up setting android:debuggable="true" and using the command line to build and deploy. Then attaching to the running process to debug.
My application is setup to build at the command line with an ant build.xml file that imports androidSDK/tools/ant/build.xml and a supporting build.properties file. I discovered that when I set android:debuggable="true" and then do 'ant release' the build process will create a debuggable apk and sign it with the release key.
I created a target in my build.xml file that I could set for this case called set-debuggable
<target name="set-debuggable" description="sets internal named property">
<echo>Setting internal named property...</echo>
<property name="set.debuggable" value="true" />
</target>
Then in my -pre-build target I added
<if>
<condition>
<isset property="set.debuggable"/>
</condition>
<then>
<replaceregexp
file="AndroidManifest.xml"
match="(android:debuggable=").*(")"
replace="\1true\2"/>
</then>
<else>
<replaceregexp
file="AndroidManifest.xml"
match="(android:debuggable=").*(")"
replace="\1false\2"/>
</else>
</if>
This creates my debuggable apk that is signed with my release key when I use 'ant set-debuggable release'. Then I use 'adb install -r myApp-release.apk' to re-install the new build. I can then launch and attach to the running application for debugging through in-app purchases.
It appears as though both IntelliJ Idea and Eclipse use a self signed debug key somewhere on your system to build and deploy a debug apk from the IDE.
In hindsight I might have been able to replace the debug key that the IDE created with my release key and attempted to get the build to sign with that key (and find the password to use the key) but the build process above took me very little time to setup and start using. If anyone goes in this direction and gets it working, please add a comment to my answer.
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