This guide will walk you through how to make a keystore in Unity, explain why it’s needed, and how to manage it securely. Whether you’re a beginner or an intermediate Unity developer, this post will help ensure you’re ready to publish your app with confidence.
When building Android apps or games with Unity, one of the essential steps before publishing to the Google Play Store is creating a keystore. A keystore acts like a secure container that holds cryptographic keys used for signing your Android applications. Without it, you cannot release or update your app.
What is a Keystore in Unity?
A keystore in Unity is a file that contains encrypted keys used to sign Android application packages (APKs or AABs). This is crucial because the Google Play Store requires every app to be digitally signed with a keystore before submission.
When you sign your app:
-
It confirms your identity as the app’s developer.
-
It ensures the app hasn’t been tampered with after signing.
-
It enables you to publish updates. Without the same keystore, you can’t push future updates to your app.
Prerequisites Before You Create a Keystore
Before diving into how to make a keystore in Unity, here’s what you need:
-
Unity installed (any version that supports Android build).
-
Android Build Support and SDK/NDK tools installed.
-
Basic understanding of Unity’s Build Settings and Player Settings.
Now, let’s dive into the process.
How to Create New Keystore in Unity
Creating a new keystore directly in Unity is straightforward. Follow these steps:
Step 1: Open Your Unity Project
Open your project in Unity. Make sure you have the Android build platform selected. If not:
-
Go to File > Build Settings.
-
Select Android and click Switch Platform.
Step 2: Access Player Settings
Navigate to:
-
File > Build Settings
-
Click on Player Settings (bottom left)
This will open the Inspector window with platform-specific settings.
Step 3: Go to Publishing Settings
In the Player Settings:
-
Scroll down to the Publishing Settings under the Android tab.
-
Look for the Keystore Manager section.
Step 4: Create a New Keystore
-
Click Keystore Manager > Create New.
-
Choose a location and name for your new .keystore file.
-
Set a strong Keystore Password.
-
Set Key Alias (like a username for the key).
-
Set a Key Password (can be the same as Keystore Password).
-
Fill in the required details: name, organization, country code, etc.
Important: Save these passwords somewhere secure. If you lose access to your keystore or forget the passwords, you won’t be able to update your app later.
Step 5: Assign the Keystore
-
Browse and select the newly created .keystore file in the Keystore field.
-
Enter the password and select the Key Alias.
-
Input the Key Password again.
Once done, Unity will use this keystore to sign your APK or AAB files during the build process.
Step 6: Build Your App
After assigning the keystore:
-
Go back to Build Settings.
-
Choose APK or AAB.
-
Click Build or Build and Run.
Your Android package will now be signed with your custom keystore, ready for submission to the Google Play Store.
Unity Create Custom Keystore
Sometimes you may need a more controlled approach to manage keystores—especially in a team or enterprise environment. In such cases, you might want to manually create and configure a keystore outside of Unity and then import it.
How to Manually Create a Custom Keystore In Unity
You can use the Java Keytool that comes with the JDK to create a keystore from the command line:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
-
-keystore: The file name of your keystore.
-
-alias: The name of your key inside the keystore.
-
-keyalg: The encryption algorithm (RSA is common).
-
-validity: The number of days the key will be valid.
You’ll be prompted to enter the password, name, organization, and other credentials. Once done, you’ll have a .keystore file ready to use.
Importing Custom Keystore into Unity
Once your keystore is created:
-
Open Unity.
-
Go to Player Settings > Publishing Settings.
-
Uncheck Custom Keystore if it’s not selected.
-
Select your custom keystore file using the file browser.
-
Enter the password and alias information.
Unity will now use your manually created keystore for all builds.
Best Practices For Keystore Management
Since keystores are critical for your app’s identity and update process, here are some best practices:
1. Backup Your Keystore
Keep multiple copies of your keystore file in secure locations (encrypted cloud storage, external drives, etc.). Losing it means losing the ability to update your app.
2. Use Strong Passwords
Use strong and unique passwords for both the keystore and the key alias. Avoid using default or guessable passwords.
3. Don’t Share Keystores Carelessly
If you’re working in a team, manage keystores carefully. Use encrypted vaults or CI/CD secrets management tools when sharing in pipelines.
4. Use Version Control with Caution
Never check in your .keystore file into a public version control system like GitHub. If using Git, add it to .gitignore.
Troubleshooting Common Issues
Unity Doesn’t Recognize Keystore
-
Make sure the path to the keystore is correct.
-
Ensure that the password and alias match what you used during creation.
-
Restart Unity after assigning the keystore to refresh settings.
App Fails to Build After Adding Keystore
-
Check your Build Settings and make sure the selected keystore is valid.
-
Look at the Console for any errors related to signing.
-
Double-check that you’re not mixing debug and release keystores.
When to Use Unity Default Debug Keystore
During development, Unity uses a default debug keystore. This is fine for testing, but never publish an app to the Play Store using the debug keystore. You must use a custom release keystore for production builds.
Migrating to Google Play App Signing
Google now recommends using Google Play App Signing, which allows you to upload a signed app using an upload key, while Google manages the release key.
Here’s how it works:
-
You create and sign your app with an upload keystore.
-
Upload it to the Play Console.
-
Google handles the rest.
This adds extra security and prevents keystore loss from blocking future updates.
Conclusion
Understanding how to make keystore in Unity is essential if you plan to release your Android game or app. It might seem like a small step in the build process, but it’s a critical one—without it, you can’t distribute or update your app on the Play Store.
To recap:
-
Use Unity’s built-in tools for quick keystore generation.
-
Or, create a keystore manually for greater control.
-
Always keep your keystore and credentials safe and backed up.
By following the steps in this guide, you’ll be well on your way to publishing secure and trusted Android apps with Unity.
FAQs
Q: Can I use the same keystore for multiple Unity projects?
Yes. You can reuse a keystore across multiple projects. Just make sure it’s securely stored and not expired.
Q: What happens if I lose my keystore?
Unfortunately, you won’t be able to publish updates to your existing app. You’ll need to re-upload the app as a new one on Google Play.
Q: Should I use the same password for keystore and key alias?
It’s not required, but it’s common to do so for simplicity. Make sure both are strong and unique.
Once you’ve created your keystore and set up the signing process, the next step is building your app for Android. If you’re not sure how to do that, this guide on How To Make APK In Unity will walk you through the process of exporting your project as an Android APK, ready for testing or publishing.