Search Unity

Unable to list target platforms.

Discussion in 'Android' started by Abdo023, Jan 1, 2018.

  1. Abdo023

    Abdo023

    Joined:
    Dec 18, 2017
    Posts:
    64
    I don't have a lot of experience with Android or Java. When I try to build to Android device I get this error:
    I have the latest version of Android Studio along with all its tools and stuff, I also installed Java 8.

    How can I fix this?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,413
    DmitryKanunnikoff likes this.
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,155
    Check Edit -> Preferences -> External Tools to see if you have the path set up there. If not you're going to want to fill out both the SDK and JDK directories.

    prefs.png
     
  4. Abdo023

    Abdo023

    Joined:
    Dec 18, 2017
    Posts:
    64
    I have the correct paths set for both sdk and jdk. I deleted java 9, but now I get these errors:
     
    Last edited: Jan 1, 2018
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,413
    it still shows jdk9 on that.. so could be the problem.
     
  6. Abdo023

    Abdo023

    Joined:
    Dec 18, 2017
    Posts:
    64
    I restarted unity and it worked, but now it freezes on the "Packaging Assets" phase while building. I restarted 3 times and same thing. I deleted the library folder and let unity generate it again and also turned off the global baked lighting thing.
     
    Last edited: Jan 1, 2018
  7. tgr_pointvoucher

    tgr_pointvoucher

    Joined:
    Oct 3, 2017
    Posts:
    3
    I am experiencing the same problem using JKD8-152. The error is:

    CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
    C:/Android/sdk\tools\bin\avdmanager.bat list target -c
    stderr[
    Exception in thread "main" java.lang.NoSuchMethodError: com.android.prefs.AndroidLocation.getAvdFolder()Ljava/lang/String;
    at com.android.sdklib.tool.AvdManagerCli.init(AvdManagerCli.java:278)
    at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:210)
    at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
    ]
    stdout[

    I can replicate the java error via the commandline, so it seems to be a problem with the Android installation.

    The funny thing is that it only fails in 2017.3 (both f3 and p1) but not in 2017.2. Same project. Same Android settings in preferences. So apparently 2017.3 also have another way of detecting the target platform - or need to do it where 2017.2 did not.
     
  8. tgr_pointvoucher

    tgr_pointvoucher

    Joined:
    Oct 3, 2017
    Posts:
    3
    Ok. So I fixed it by renaming the avdmanager.bat file as I noticed that it was not present on one of my other platforms that build fine. I don't know what I have broken in Android tooling doing that, but at least Unity can build now.
     
  9. DmitryKanunnikoff

    DmitryKanunnikoff

    Joined:
    Jul 9, 2017
    Posts:
    4
  10. Shammo_BD

    Shammo_BD

    Joined:
    Mar 5, 2018
    Posts:
    1
    Same issues here man,worked just fine before update,so dissappointed man.
     
  11. lebustamant

    lebustamant

    Joined:
    May 21, 2018
    Posts:
    1
    I've got exactly the same Error and your solution worked. Who knows if that messes up my Android Studio for other purposes, but it did the trick. Thank you! I wonder if this problem is listed somewhere in the release notes, how can the Unity development team not notice such a basic problem?
     
  12. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
  13. Desertleaf

    Desertleaf

    Joined:
    Dec 15, 2013
    Posts:
    15
    Hi, im having the same annoying issue but im clueless as to what is not being found - the JDK or the SDK.

    Prior to seeing this post,

    i was using unity 2017.1.0f3, and could not get unity to build to android using SDK tools from version 24.0.0 to 28.0.2. I was using JDK10. I installed to unity 2018.2.0F2, same problem occurred.

    Saw this post,

    removed all JDKS, installed JDK8 update 181, uninstalled Android Studio, reinstalled andriod studio and its default SDK. I still get the same error.

    CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
    B:/Work/Java\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="C:/Users/Red2Black/AppData/Local/Android/Sdk\tools" -Dfile.encoding=UTF8 -jar "B:\Work\Unity 2018.2.0f2\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar"

    I dont know what to do, Im dying inside out.
     
  14. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    What is the output of
    B:/Work/Java\bin\java.exe -version
    ?
    What is the output of
    java -version
    when the current directory is, for example, B:?
     
  15. halken

    halken

    Joined:
    Mar 11, 2017
    Posts:
    7
    Had the same issue. Fixed by installing JDK 8. Note, even though java.exe -version reported 8, the other version was still interfering. I had to uninstall JDK 10 and suddenly it worked.
     
    Yury-Habets likes this.
  16. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Correct. Oracle installations add latest java executable to your PATH, which interferes with Android SDK.
     
  17. Shenanigans2

    Shenanigans2

    Joined:
    Jul 8, 2018
    Posts:
    4
  18. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    DON'T DO THAT!
     
    DBarlok likes this.