How can I specify location of debug keystore for Android ant debug builds?
You can remove the signature of the final apk and sign it again. It is just a debug build so the zipalign can be avoided (at least I have no problems in my build).
Copy your keystore to a file debug.keystore in the project and add the following in ant.properties
debug.key.store.password=android
debug.key.alias.password=android
debug.key.store=../debug.keystore
debug.key.alias=androiddebugkey
And add the following in your build.xml
<target name="-post-build" if="${build.is.packaging.debug}">
<!-- Remove the signature of the debug build, and sign it again with our own debug keystore -->
<delete dir="tmp" includeemptydirs="true" failonerror="false" />
<mkdir dir="tmp" />
<unzip src="${out.final.file}" dest="tmp" />
<delete dir="tmp/META-INF" includeemptydirs="true" verbose="true" failonerror="true" />
<delete file="${out.final.file}" failonerror="true" />
<zip destfile="${out.final.file}" basedir="tmp" />
<delete dir="tmp" includeemptydirs="true" failonerror="false" />
<echo level="info">Signing final DEBUG apk with a common signature...
signapk
input="${out.final.file}"
output="${out.packaged.file}"
keystore="${debug.key.store}"
storepass="${debug.key.store.password}"
alias="${debug.key.alias}"
keypass="${debug.key.alias.password}"
</echo>
<signapk
input="${out.final.file}"
output="${out.packaged.file}"
keystore="${debug.key.store}"
storepass="${debug.key.store.password}"
alias="${debug.key.alias}"
keypass="${debug.key.alias.password}"/>
<delete file="${out.final.file}" failonerror="true" />
<move file="${out.packaged.file}" tofile="${out.final.file}" failonerror="true" />
</target>
Setting the location of debug.keystore for command-line build without rewriting Ant targets
In .bashrc
, set the ANDROID_SDK_HOME
environment variable to the location of your Android SDK installation. For example:
export ANDROID_SDK_HOME="/home/myusername/path/to/androidsdk"
Then, in a new shell, running ant debug
creates a ${ANDROID_SDK_HOME}/.android/debug.keystore
file.
Alternatively, without changing the variable globally, you can simply run:
ANDROID_SDK_HOME="/home/myusername/path/to/androidsdk" ant debug
Where is debug.keystore in Android Studio
EDIT
Step 1) Go to File > Project Structure > select project > go to "signing" and select your default or any keystore you want and fill all the details. In case you are not able to fill the details, hit the green '+' button. I've highlighted in the screenshot.
Step 2) VERY IMPORTANT: Goto Build Types> select your build type and select your "Signing Config". In my case, I've to select "config". Check the highlighted region.
Can I build my Android app as debug but sign with release keystore
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.
How to set a custom keystore for debugging in eclipse for android
I had the same issue and here are the steps to properly create a custom keystore that can be used for debugging in Eclipse:
Basically what you should do is that change both storepasswd
and keypasswd
for the alias androiddebugkey
to "android".
Here are the commands:
keytool -changealias -keystore mykeystore.keystore -alias [old alias] -destalias androiddebugkey
keytool -keypasswd -keystore mykeystore.keystore -alias androiddebugkey
keytool -storepasswd -keystore mykeystore.keystore
If you don't know your old alias, look it up using
keytool -list -v -keystore mykeystore.keystore
in Command prompt not able to enter the password
Is there a way to use a custom keystore while building an android app using ant on debug mode?
Per my research so far, the only way is to achieve this is to copy the keystore file to the default android keystore path (which is generally located under ~/.android directory.
There is no debug.keystore in .android folder
According to the documentation, performing a build in Eclipse or using ant debug
should automatically generate ~/.android/debug.keystore
.
But in case this doesn't work, you can create one manually by running:
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
How can I change the location of the Android debug key store?
Change the environment variable
"ANDROID_SDK_HOME"="C:\your\path\"
then you can put the .android directory there and the build will search for the debug key there.
how to solve this error 'debug.keystore not found inside c:\Users\kulde\.android\' while creating Android Signing Certificate SHA-1
Instead of using debug.keystore
which is less secure use your own created keyStore. Follow this to do the same
After you created your keystore, run the following command in terminal of Android studio.
keytool -list -v -keystore "path where .jks file is stored"
After this terminal will ask for password which you have created in above step.
Finally you will get your SHA-1 certificate.
Make sure you store your keystore safely. It will be used in future when you upload your App.
Related Topics
Constraintlayout Chains and Text Ellipsis + Image on The Right
How to Create Listview Inside Dialog
Combining Two Bitmap Image (Side by Side)
How to Hide The System/Navigation Bar in Android Ics
Android: Wait on User Input from Dialog
Videoview Onresume Loses Buffered Portion of The Video
How to Use Percentage for Android Layout
Android: Execute Code in Regular Intervals
Mediarecorder Issue on Android Lollipop
Android: Share Session Between Webview and Httpclient
How to Load Image as Bitmap to Glide
How to Find The Amount of Free Storage (Disk Space) Left on Android
Android: Refreshing The Gallery After Saving New Images
Ble Scan Is Not Working When Screen Is Off on Android 8.1.0
Music Player Control in Notification
How to Look-Up a Contact's Name from Their Phone Number on Android