17

I have a problem showed on this screenshot: https://imgur.com/a/VGHrpVV

The problem has appeared when I imported GoogleMobileAds package to insert AdMob ads to my project. I tried to create 2 local variables "JAVA_HOME" and "PATH" in environment variables using this guide https://null-code.ru/solution/157-reshenie-exception-jar-not-found-windows.html , but it doesn't help me.

Evorlor
  • 6,722
  • 16
  • 66
  • 130
JediMan4ik
  • 185
  • 1
  • 1
  • 6

10 Answers10

44

It is a Unity bug. To fix:

Edit->Preferences->External Tools
Uncheck Android SDK Tools Installed with Unity (recommended)
Press Browse -> It might update the filepath
Recheck Android SDK Tools Installed with Unity (recommended)

Then:

Assets->Play Services Resolver->Android Resolver->Resolve

This has been tested and works with Unity 2019 and Unity 2020.

Evorlor
  • 6,722
  • 16
  • 66
  • 130
  • 3
    Thanks, solved the problem with Unity 2019.2.19 too – PGibouin Jan 31 '20 at 12:07
  • 1
    .. and 2019.3.0f6 :) – 01F0 Feb 16 '20 at 10:00
  • 1
    Something like that worked for me on Linux Mint (Ubuntu-based distro). I just had to agree to the suggested JDK version after I unchecked the Installed SDK Tools option, then I checked it again. – Vladius Apr 19 '20 at 12:28
  • 1
    This generally seems to work, but you may need to do the same process with the JDK path setting instead of the SDK one. – Marconius May 20 '20 at 08:07
  • muchas gracias senior – bturner1273 Mar 11 '21 at 23:55
  • In Unity Hub, go to Installs and click the dots to open 'Add Modules' and ensure when expanding the Android Build Support dropdown you have both Android SDK & NDK Tools and OpenJDK selected. – zzzzzz May 10 '21 at 23:13
  • 1
    I also had to delete "C:\Users\\[USER_NAME]\.gradle" folder. – Alireza Aug 21 '21 at 10:03
  • 1
    Worked for 2021.1.21f1, thanks! – Yern Oct 02 '21 at 12:12
  • In 2020.3.16f1 I actually had my Android SDK Tools Installed with Unity (recommended) unchecked by default. Checking it solved my issue. (which is odd because I had built an apk just a few days ago without any issues) – Display name Apr 03 '22 at 02:47
5

try Assets-> Play Services Resolver-> Android Resolver-> Delete Resolved Libraries

Pranav Mehta
  • 124
  • 1
  • 4
1

check is your Java set true or not: go to cmd and type JAVA -version if this appeared means your JDK is set if not check this link: https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html

after these, if you have the problem again update your JDK from https://www.oracle.com/technetwork/java/javase/downloads/index.html

Ali Amini
  • 176
  • 1
  • 1
  • 11
0

i was using admob plugin in my project and this is how i resolved the issue after trying all given solutions.

  • reimport the admob plugin / plugins you are using in your project. (i just reimport the latest version of admob plugin and issue resolved)
0

For me it was similar to this answer https://stackoverflow.com/a/57361245/2149955 but just a bit different so sharing a separate answer for when you haven't installed the tools through unity hub.

In Unity:

Edit->Preferences->External Tools
See error messages "You are missing the recommended <TOOL>. Install the recommended version using Unity Hub"

In Unity Hub:

Installs -> My Unity Version -> ... -> Add Modules, Twirl open Android Build Support -> Check Android SDK & NDK Tools (I also checked OpenJDK)
Press Next -> Accept Terms
Wait for install to finish

After that finishes, back in Unity:

If you look in external tools again, the error messages will be gone
Assets->Play Services Resolver->Android Resolver->Resolve
Patrick Fay
  • 538
  • 3
  • 15
0

Update to Unity 2019.4.10f fixed it

Roy
  • 11
  • 1
0

When I wanted to make an app for Android, I got this and many more as errors. Nothing worked, including the solutions here. I tried both Unity versions 2020.3.5f1 and 2019.4.22f1, it didn't work.

I figured out that the problem was due to "Android Built Support" not being fully installed. I did the following and the problem was gone:

  1. Unity Hub (my version 2.4.3) -> from the left menu, go Installs
  2. Click the 3 dots in the upper right corner of the Unity version you want (I used 2019.4.22f1) -> Add Modules
  3. From Platforms, find "Android Built Support"
  4. Its check box was checked because I installed it before, but if you don't have it, first install it
  5. Display its submodules with the arrow to its left; "Android SDK & NDK Tools" and "OpenJDK"
  6. Check their check boxes, next and install
  7. Restart Unity
  8. When you open the project, it resolves
  9. It gave me another warning after the resolve, so I made sure that the problem was gone by doing "Assets->External Dependency Maneger->Android Resolver->Force Resolve" in the project again.
Beyza Kurt
  • 11
  • 1
0

I faced this error when I wanted to build for Android. The reason I have faced this is that I had 2 Unity versions (2019.4.9f1 and 2020.3.3f1), and my JAVA_HOME was configured to use the java folder inside 2019.4.9f1. I then uninstalled and removed 2019.4.9f1, and after that, I got this error when trying to build in 2020.3.3f1.

  1. I changed my JAVA_HOME variable permanently, following the link below: How to set JAVA_HOME in Mac permanently?

  2. Restarted my Macbook.

  3. Went to Unity -> Preferences -> External tools, unchecked NDK, JDK, etc., clicked the Browse button that appeared, and selected the folder under 2020.3.3f1 manually for JDK.

(In the end, no folder should change when you uncheck and check again)

enter image description here

Onat Korucu
  • 765
  • 9
  • 13
0

Simple fix. I got this message about Missing the JDK. If you have one that is similar or pointing to the wrong JDK you can try this fix.

Here is the Error I was getting: enter image description here

I solved this by:

  1. In Unity goto "Edit->Preferences->External Tools"
  2. Unchecked the box "JDK Installed with Unity (recommended)", and noticed that the Path was pointing to an Old version of Unity I had uninstalled.
  3. Changed the Path to the current version of Unity I am usings, OpenJDK directory.
  4. Re-checked the box "JDK Installed with Unity (recommended)"

Then was able to build my game, and build to my android phone just fine. Note: If your having problems with the SDK or NDK you could try this solution, by unchecking, and re-checking their respective boxes.

Dharman
  • 26,923
  • 21
  • 73
  • 125
Jim Kniest
  • 91
  • 5
0

This Worked For me: If u had rectified JAVA_HOME, JDK SDK files & every possible way and solution does not show up try

preference -> in android untick the JDK installed.., if you see a change in directory then just re tick, copy path of JDK and uncheck, finally paste the path close(x) preference TRY BUILD & RUN Next time you open Unity Editor then try to check & uncheck JDK we have to see the same directory both ways

Karthik
  • 1
  • 2