Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Building From Unity right onto Android Device

Discussion in 'Android' started by Nduel, Dec 14, 2015.

  1. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Hi everyone, I'm having a small issue. I cant find the right steps to loading the proper SDK onto my Android Device. I made a level to load onto the Samsung VR and need to build it right onto the Android phone. On my PC I have Android Studio and the Java DK but I'm running into a dead end on what to load for the device. Any direction/links or suggestions would greatly be appreciated, thanks.
     
  2. Metastable

    Metastable

    Joined:
    Apr 10, 2013
    Posts:
    50
    Make sure you have the correct Platform selected and then simply choose Build & Run which will load the apk onto your device. This assumes that your phone is already in developer mode and has been recognized by your computer as such.
    http://docs.unity3d.com/Manual/android-sdksetup.html
     
  3. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Ok, thanks for your response. I just went ahead and installed all the stuff in the SDK manager in Android Studio. When the device I was using comes to the office it seems like getting the device to be properly recognized is the main issue here. Which is what I was struggling with last week. I'm almost there ::crosses fingers::
     
  4. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    So I have all the drivers installed, the SDK and the the phone is being recognized but Unity itself isnt recognizing the phone yet. I'm having this same problem this person had. I don't understand the solution. Do they mean opening the command prompt window in windows? Or is there a command console in Unity that I just cant find? I appreciate your help/patience.
     
  5. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    On your PC ...go to "Start Button" type "Command" in the Search prompt and it should show a "Command Prompt" action in the window...hit enter to start a "Command Prompt Window / Terminal"

    This is where you type in you command(s) like "adb devices" will list all the devices attached to your PC by USB cable

    Also make sure when (after) you attach your device to your PC via cable "swipe down" from the top of your device and
    try "MTP" or "PTP" settings ....on your device every device is different these days...it seems ;)

    This is assuming you have your device in DEBUG mode....inside your "developer menu" in your device settings...

    EDIT: Also make sure your Android SDK is in your path on your PC...or "adb devices" will be
    a NON recognized command...there are also youtube videos on how to add paths to your
    pc machine...pretty easy... ;)

    Hope this helps
    Lar
     
    Last edited: Dec 14, 2015
  6. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Thanks Lar,
    Yea right now "adb devices" isn't being recognized -__-

    EDIT: Also the phone is setup for Debug mode and the path in the external tools of Unity is set in the Android root folder of the SDK
     
  7. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    So when you type ..."adb devices"..your getting 'adb' is not recognized as an internal or external command....is
    this correct..?
    If that's the case then your Android SDK is NOT in your "Windows Path"..

    Check this little vid out and see if it works...



    Good Luck...and let me know...it should be something like ...: C:\Program Files (x86)\Android\android-sdk\platform-tools
    Just make sure Windows can find the "adb" program and you should be set ;)

    Lar
     
    Last edited: Dec 15, 2015
  8. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    I feel like we're getting closer to a solution here. When I go into LocalC:>Users>Username>.android I get this displayed but no 'adb' application.

    adb.jpg


    Now in the directory of LocalC:>Program Files (x86)>Android.android-sdk I don't get any 'adb' files, even in the tools folder. So, super frustrating. :(


    sdk2.jpg
     
  9. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    Did you happen to look in the other directories in there...'platforms'.....do a search for 'adb.exe'...etc...

    You installed the Android SDK right....or did some else...?

    Just wondering if it's a old install ...or new...

    Looking at your directories there...you don't have 'platform-tools'...that's usually where 'adb'
    resides...you may have to go back and select install tools when you installed the SDK...

    This may help also... www.howtogeek.com/125769/how-to-install-and-use-abd-the-android-debug-bridge-utility/


    Lar

    P.S. I normally use my iMac for development...my Windows laptop I use for a server...been
    a while since I developed on my laptop... ;)
     
    Last edited: Dec 15, 2015
  10. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Thanks! I'm going to run through everything I'll keep you updated.
     
  11. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    Not trying to hijack your topic, but is this possible on iOS, too?
     
  12. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Ok, so for some reason the 'adb' resided in a folder called, 'adt-bundle-windows-x86-20140702' that was sitting on my desktop. I moved the folder into the C: drive here:
    adblocation.jpg
    I then rerouted the path and ran a test and the adb command is registering(HOORAY!):
    adbdevice1.jpg

    I routed my 'External tools' from Unity to that folder, 'adt-bundle-windows-x86-20140702':
    externaltools1.jpg
    Restarted Unity, plugged in the Android Device........Nothing. So as big of a progress we've made I hit a wall...again. I'm not too sure where to go from here now.
     
  13. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    O.K...what we need to do is get the CONTENTS of that directory into your 'Android SDK' directory...the one you posted above ....in one of your replies ....***Now in the directory of LocalC:>Program Files (x86)>Android.android-sdk***

    ALL your SDK tools...etc...ADB...etc need to be in one place...so Unity and your Command
    prompt will find what it needs...when it needs it... ;) then you will be able to build out to
    devices and desktop..and the 'ADB' (Android Debug Bridge) will be able to connect to all
    attached devices via USB cable...(after you put your device into Developer Debug Mode)..

    >>>>You want this directory...your 'ANDROID SDK' directory <<<<<
    -->Program Files(x86) -->Android-->android-sdk


    ..your going to MAKE a directory ....'platform-tools'... --->

    (directory structure as below..)
    add-ons
    platform-tools
    (the one your'e going MAKE and put the CONTENTS of 'adt-bundle-windows-x86-20140702' this directory, it should have the ADB in it)
    tools
    AVD Manager
    SDK Manager
    ...etc

    ..after you you have made your 'platform-tools' directory...--->

    ..so your -->android-sdk DIRECTORY structure should look some thing like this....some minor differences...may occur..(additional directories / files ...etc)

    *******
    add-ons
    platform-tools
    tools
    AVD Manger
    SDK Manger
    ..etc
    ********

    Don't copy the NAME....just the contents of 'adt-bundle-windows-x86-20140702' into 'platform-tools' when
    your done the 'ADB' should be directly UNDER 'platform-tools'...and of course all the other files in that go along
    with 'ADB'

    After that make sure your 'WINDOWS' path that you should of edited to make the 'ADB' work...points to the 'ADB' path
    again...

    THEN back to Unity and point that path to the 'HOME' directory of your 'SDK' NOT the 'ADB' just the WHOLE
    SDK directory...something like above...'c:\Program Files(x86)\Android\android-sdk'...

    reboot your machine and everything should work....

    'adb devices' from the command prompt....etc...

    Unity should connect to your Device when you build....etc


    ***********************
    Do a test project..just a light...and a cube and build it out to your device

    DON'T forget under Unity ...Edit --> Project Settings --> Player ...set all the settings you need to

    (the most important one(s)...Under Other Settings.....-->'Bundle Identifier' and Under Publishing Settings -->
    'Key Store'...unless you have built a 'key store' file...just use 'Create New Keystore'

    After that under -->File -->Build Settings ...a window pops up...Build or Build and Run...

    Try the Build and Run....If your device is connected to your pc...

    Build just builds the .APK file to your hard drive...

    .../takes a breath....wow...a book later..

    Hope this helps...

    NOTE: If you can't build to your device, try to build for your PC desktop...-->File-->Build Settings... click on PC, Mac..etc and click on 'Switch Platform'....then hit the build button
    and see what you get....

    Lar

    P.S. When you get this all working...Run your 'SDK Manager' and install the Android platforms
    you want to develop for...
     
    Last edited: Dec 16, 2015
  14. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    @Shushustorm ...IOS is another story..not the same at all...

    ;)
    Lar
     
    Shushustorm likes this.
  15. addicus

    addicus

    Joined:
    Apr 6, 2014
    Posts:
    25
    Sorry I just skimmed this thread because I had the same issue at one point. Have you gotten the phone to pop up onto your desktop / 'choose what to do with this device' type message? For me that was the point when I was then able to build to the phone from Unity. Make sure that (on your android phone) in your Settings > Developer options that you have Developer options set to ON and USB debugging has a green check mark next to it / is also turned on.

    Also try different USB ports if its still not recognized by your machine. Or try pulling down your notifications menu and classifying the phone as a media device or whatever the other option is when you plug the phone in. I just messed around with all those variables for a while and eventually my computer recognized my Note 4 and I was able to build to my phone and test builds in the Gear VR.

    Cheers
     
  16. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    This was tremendously helpful! Unity still wont recognize the phone though so I tried to just make a basic build and then drag the APK in. It wont even build the scene with the 'OVR' POV Player controller, Its giving me an asset error. if I remove the assets it will build. SO....Do I revert back to an older version of Unity? I cant locate the updated VR assets on the Oculus Dev site. I'm just about there. error.jpg
     
  17. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    ....looks like that one is ---> Obsolete
    Use EditorSceneManager to see which scenes are currently loaded

    http://docs.unity3d.com/ScriptReference/EditorApplication-currentScene.html

    You may have to try a older version of Unity ..to see if that may fix the problem, or look at your --> errors and warnings and try to fix them...NOTE: Warning(yellow flags) will not keep your script from compiling tho...Just ERRORS (red flags)

    Any more info would help..

    Keep me posted

    Lar

    P.S. I've never played around with the Oculus (stuff) before...interesting o_O
     
  18. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Ok thanks! I will keep you updated.
     
  19. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    So I decided to build the scene for PC instead of Android and it works fine. It's just a bare bones house interior with a POV Character controller. Works fine on my DK2 that's great and all but it needs to be built out for android.

    Problem is, nothing will build out for Android. It keeps telling me to update my tools SDK
    updateBS.jpg

    Even though Ive updated all the tools in my SDK Manager
    toolversions.jpg
    When I tell it to update (through Unity prompting me) it acts like its doing something but then continues to ask me to update it making no progress on the progress bar.

    If I just click 'continue' it just fails and errors out
    error buildingplayer.jpg failed.jpg

    For as much progress as we made, this Android debacle feels like its turned into a fiasco. Any thoughts on this?
     
  20. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Anyone know a link for Unity 4.6 versions? I'm having a bit of an issue finding it.
     
  21. Yowling-Cat-Games

    Yowling-Cat-Games

    Joined:
    Dec 11, 2014
    Posts:
    37
    ...link to 4.6
    http://unity3d.com/get-unity/download/archive


    Have you tried to update your SDK by going to the directory where it is installed and run the 'SDK Manager' from
    there and let it update...don't have any other software running at the time...close all other windows...let it update..
    may take some time...

    Lar
     
  22. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    Wow I cant believe I couldn't find the archive for Unity, thanks! I'm going to give this a go, your help has been tremendous!
     
  23. Nduel

    Nduel

    Joined:
    Dec 14, 2015
    Posts:
    13
    So after all of this part of the reason why it wasn't sending the build to the phone was because I didn't have the pro version . I have everything working right now (thanks to you). Now my hurdle seems to be reopening builds to run on the Samsung gear, they just sit there.