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. Dismiss Notice

Android Build Fails As Of This Morning

Discussion in 'Android' started by mdswanson, Jun 7, 2019.

  1. mdswanson

    mdswanson

    Joined:
    Apr 11, 2016
    Posts:
    7
    This morning, I fired-up Android Studio on my PC and accepted its update request. While I'm not 100% sure that the Android Studio update is the cause, I can no longer successfully build an Android project in Unity 2018.3.7f1 (or 2018.3.14f1).

    I've uninstalled and reinstalled Android Studio, the Android SDK, and Unity, yet I receive the same error when I try to build. This happens with both of my Android projects along with a brand new project with nothing added to it.

    Here's the error I get:

    FormatException: Input string was not in a correct format.
    System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Int32.Parse (System.String s, System.IFormatProvider provider) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    System.Convert.ToInt32 (System.String value) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    UnityEditor.Android.AndroidDeviceInfo.get_SDKVersion () (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.AndroidDeviceInfo.HasSDKSupport (System.Int32 minimumVersion) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.AndroidDeploymentTargetsExtension+AndroidDeploymentTargetInfo.CheckTargetInternal (UnityEditor.Android.AndroidDeploymentTargetRequirements targetRequirements) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.AndroidDeploymentTargetsExtension+AndroidDeploymentTargetInfo.CheckTarget (UnityEditor.DeploymentTargetRequirements targetRequirements) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckDevice.FindCompatibleDevices (UnityEditor.Android.AndroidDeploymentTargetRequirements targetRequirements, UnityEditor.DeploymentTargets.DeploymentTargetId targetId, System.Collections.Generic.List`1[T] knownDevices, System.Collections.Generic.List`1[UnityEditor.Android.PostProcessor.Tasks.CheckDevice+DeviceInfo]& compatibleDevices) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckDevice.GetTargetDevices (UnityEditor.Android.ADB adb) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckDevice.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at <76abbd884b37447da464288ec1125ab8>:0)
    UnityEditor.PostprocessBuildPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:106)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

    Does anyone have any ideas about what might be going on?

    Thanks.
     
    SteveHinan likes this.
  2. mdswanson

    mdswanson

    Joined:
    Apr 11, 2016
    Posts:
    7
    Interestingly, Build does work. It's Build and Run that fails before it starts the build process. Any ideas?
     
  3. culage

    culage

    Joined:
    Jul 3, 2018
    Posts:
    2
    I solved this problem using the Windows feature "restore point".
     
  4. SteveHinan

    SteveHinan

    Joined:
    Nov 5, 2014
    Posts:
    10
    @mdswanson I have the same problem after updating Android Studio yesterday. I don't have a workaround yet.
     
  5. culage

    culage

    Joined:
    Jul 3, 2018
    Posts:
    2
    If possible, try unity2019.1.
    unity2019 includes the JDK and Android SDK that do not show an error. (You do not need to prepare AndroidSDK)
    Finally I decided to use unity2019.1.
     
  6. SteveHinan

    SteveHinan

    Joined:
    Nov 5, 2014
    Posts:
    10
    @culage
    This is my first time learning to use restore points and will be ready for the next time.
    I can not upgrade from 2018.4 -> 2019.1 as internal build has been deprecated and gradle is not working for my project.

    I want to uninstall Android Studio and reinstall an older version but can't yet find older versions of Android Studio to install. Any advice would be great.
     
  7. SteveHinan

    SteveHinan

    Joined:
    Nov 5, 2014
    Posts:
    10
    Last edited: Jun 9, 2019
  8. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    186
    @SteveHinan
    I suggest that you should fix whatever problems you are facing with Gradle. AFAIK, Google/Android is bent on phasing out the old build/archiving system completely and is embracing Gradle fully. Unity, in compliance to Android system, is also phasing out the internal build.
    If you are attempting to do post-processing on apk builds, depending on what you are attempting to do, there are post-processing events which occur before the final archiving and after archiving.
    For example, if you wish to amend the resources/manifest file before archiving, you might want to take a look at https://docs.unity3d.com/ScriptReference/Build.IProcessSceneWithReport.html .
    If you are doing custom resigning of archive, use https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuildWithReport.html .
    My projects also utilized tons of such build scripts which during upgrades, I had to manually scan through and rewrite them to fit the new Gradle process (which I sort of gave up eventually and exported to an Android Project instead and do everything via postprocessbuild)
     
    SteveHinan likes this.
  9. peachpieproductions

    peachpieproductions

    Joined:
    Sep 2, 2017
    Posts:
    17
    @mdswanson Was anyone able to solve this? I have tried everything I can think of. I have been able to get 2019 working, but I cannot get any of the 2018 unity versions to build to android.
     
  10. chenhaohuang

    chenhaohuang

    Joined:
    May 30, 2019
    Posts:
    2
    Same problem here, i can only build, when doing build and run it fails.
    2018.3.14f1
     
  11. mdswanson

    mdswanson

    Joined:
    Apr 11, 2016
    Posts:
    7
    @peachpieproductions I haven't figured out a way around this issue, so I've been using Build by itself, then manually installing the .apk using adb. Certainly not ideal. Still looking for an answer/workaround.
     
  12. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Could you execute

    adb shell getprop ro.build.version.sdk

    command and see what it outputs?
     
    SteveHinan likes this.
  13. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    24
    Having same issue. 2018.4.2f1 Build/Run fails (I've also been doing the build and manual copy and install to get by). 2019.1.5f1 Build/Run works fine with the embedded android sdk.

    In 2018.4.2f1, I can see my run device show up as just the numeric identifier whereas in 2019.1.5f1, it shows up as Samsung SM G955U1 (numeric identifier)

    @Tomas1856 adb shell getprop ro.build.version.sdk for me shows output-> 28
     
  14. mdswanson

    mdswanson

    Joined:
    Apr 11, 2016
    Posts:
    7
    adb shell getprop ro.build.version.sdk for me returns:25

    Also, my list of devices only shows a numeric identifier (if that matters).
     
  15. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Hmph, looks fine, can someone attach Editor.log?
     
    SteveHinan likes this.
  16. SteveHinan

    SteveHinan

    Joined:
    Nov 5, 2014
    Posts:
    10
    @Tomas1856
    adb shell getprop ro.build.version.sdk = 25
    Unity 2018.4.1
    Android 'Internal' build
    editor log attached.
     

    Attached Files:

  17. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    24
    Not sure exactly which component fixed it, but now able to successfully build/run in 2018 again. Its been a while since I'd ventured into android's SDK Manager, and I saw that I had a mis-mash of platforms and tools downloaded. I just started playing around with ARFoundation which is why this probably cropped up for me, requiring minimal level 24 for ARKit, etc.. I think I hit the button that had Unity upgrade my SDK and I'm curious if things went out of whack there. Anyways, the problem appears to have corrected itself after I downloaded the matching Build tools and SDKs for the target platforms.
    Incidentally, just to see if it worked, I pointed my 2018.4's Android SDK path to my 2019.1.5 embedded android sdk which is at: C:/Program Files/Unity/2019.1.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK
    ..and build/run works fine also.

    upload_2019-6-13_17-51-34.png
     
    SteveHinan and JStronglyTech like this.
  18. SteveHinan

    SteveHinan

    Joined:
    Nov 5, 2014
    Posts:
    10
    Fixed! Android studio just added another update, so I updated and the problem went away, I also deleted the contents of my UnityProject - Library folder, so not sure which item solved the problem, but it's solved! And I can now build with Gradle after deleting my UnityProject - library folder.
     
    Last edited: Jun 14, 2019
  19. mdswanson

    mdswanson

    Joined:
    Apr 11, 2016
    Posts:
    7
    Indeed...I updated Android Studio (I think it was an upgrade to Android SDK Platform-Tools 29.0.1), and everything is working fine again. Thanks to everyone for digging in!
     
    SteveHinan and JStronglyTech like this.
  20. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    265
    I can confirm updating from 29.0.0 to 29.0.1 resolved the issue for me.
     
  21. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    THIS!!!! After updating I was still getting the errors, but deleting my library folder and restarting fixed it! :D