Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 28, 2020 at 08:04 AM by Hellium for the following reason:

Self-answered question

avatar image
1
Question by akash_virodhia · Mar 28, 2020 at 07:47 AM · buildbuild-errorsdkapkbuilding

How to build android apk in Unity?

My Unity version is 2018.4.12f1, but the steps for building an APK are pretty much same for any Unity Version.
Making a game in Unity is one thing and building it successfully is another mammoth task due to the errors one had to face while building. Fear not, I list the steps, how I built my APK. So this would be a self answered question so as to help others in building their APK.

STEP 1 : Creating keystore and key

  1. First thing first make your game.
  2. Go to File > Build Settings in Unity editor.
  3. Select Platform as Android ( in build settings) if not done already.
  4. Click on Player Settings... button. Fill out Company Name, Product Name , Version and choose a Default Icon for your game.
  5. Now, click the little Andorid icon tab in the inspector pane. A tab will appear named Settings for Android.
  6. Under Settings for Android, you will find various options such as Icon, Resolution and Presentation, Splash Image, etc.
  7. Click on Publishing Settings. Tick mark Create a new keystore... . Then press Browse Keystore. A window will appear select location for your Keystore. and give filename as "yourkeystorename.keystore". Then set Keystore password and confirm it.
  8. Now, Create Key. In Alias by default, it is Unsigned (debug). Change that to Create a new key.
  9. A window will appear fill the Alias and password and confirm the password field. (NOTE : password has to be same as the keystore password we created in step no above).
  10. Then, press create key button. Now the key has been created and change the Alias from Unsigned (debug) to your key that you just created.
  11. Enter the password and you're ready to build your apk.


STEP 2 : Installing SDK and JDK

But I didn't have Android SDK installed. So Building apk showed ERROR: Unable to detect SDK in the selected directory.

  1. So I downloaded "Android Version 3.6.1 for Windows 64-bit" (749 MB) from this link: https://developer.android.com/studio. For Installation, it's easy, just click next throughout the installation. (For me this also automatically installed JDK)
  2. Now set the SDK and JDK location in Unity. Go to Edit>Preferences>External Tools.
  3. Browse and choose the location where SDK is installed and Tick the Use embedded JDK check-box.
  4. To know where Andoird SDK is located, steps are :
    Open Up Android Studio, and then Go to 1. Configure 2.Project Defaults 3.Project Structure there you have SDK location.



STEP 3: Fixing the ERROR: Unable to detect SDK in the selected directory. (Even when SDK is installed)

Even After SDK was installed it was showing the same ERROR: Unable to detect SDK in the selected directory.

  • I noticed that the in the SDK location "tools" named folder was missing.
    If it is not missing then I would recommed deleting it.

  • Fix it by downgrading the android sdk tool version.

  • The steps : .

  1. Delete android sdk "tools" folder : [Your Android SDK root]/tools -> tools
  2. Download SDK Tools: http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
  3. Extract that to Android SDK root
  4. Build your project



STEP 4 : Additional Build problems

Hopefully, your APK should be built without any errors.

But during the build, the APK it was stuck at "building gradle project". To fix that ensure that you've set the keystore and key in the publishing settings.

After all this I was finally able to build my APK. :'-)

Answer ends here


Hope this all helped, if you have any suggestions and fixes for problem related to building an APK please post it here so that others can also take help from it.

The Motivation behind this post was to save all the work at one place that one had to do while building an APK.

Again, Unity version used was 2018.4.12f1, but the steps must be applicable to pretty much any recent or old Unity version you are using.


---------------Helpful Links Related to this answer:

  1. Not finding Android SDK (Unity)

  2. Downloading and Installing Andriod SDK, normally SDK installation also installs JDK with itself

  3. Video on Creating KeyStore and key in Unity

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Can't build my game! 1 Answer

Android app bundle(aab) build problem 2 Answers

APK Builder Failed 2 Answers

Build in Gradle 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges