- Home /
How to sign APKs for publish when using BuildPipeline.BuildPlayer
I was wondering if there are any particular steps I need to take to successfully sign APKs when using BuildPipeline.BuildPlayer()?
I have successfully built and uploaded APKs when using the "build" option in the editor but when building via BuildPlayer() I get an "Unable to read " followed by "Keystore was tampered with, or password was incorrect" but the password entry in the editor hasn't been changed since the last successful build. PlayerSettings.keystorePass and PlayerSettings.keyaliasPass are set to the correct values, it is as though they just aren't being picked up.
Using an unsigned alias with BuildPipeline.BuildPlayer() also works just fine. Is it the case that I have to build an unsigned APK then sign it via the command line as in the following post?
http://forum.unity3d.com/threads/signing-package-from-the-command-line.162448/
Please check if the keyalias and keystore are set to the correct values. Remember that keystore must be a string with full path to file...
Hey Denvery, is there some way of setting the keystore path in code? The only place I can see is through the editor in "Player Settings". The path I have set there works just fine when I do File->Build Settings->Build but if I call BuildPlayer() without changing any settings it fails.
Strangely this seems to have just started working this morning. Can't identify what was causing the issue before.
Answer by Denvery · Jun 24, 2014 at 10:16 AM
Hi BarneyW, this is an example of signing APK from code:
PlayerSettings.Android.keystoreName = keystoreName;
PlayerSettings.Android.keystorePass = keystorePassword;
PlayerSettings.Android.keyaliasName = keyAliasName;
PlayerSettings.Android.keyaliasPass = keyAliasPassword;
We write these lines inside C# script and call these function when we are building. keystoreName contains full path to keystore file. May be this will help you a bit:)
Answer by JigneshKoradiya · Jul 28, 2015 at 09:50 AM
you have to visit this video to understand keystore :
you can sign the apk with keystore