当前位置: 首页 > 知识库问答 >
问题:

Android SDK没有正确安装错误,当我试图为一个游戏建立apk文件时,我正在用Unity开发?

黄丰
2023-03-14

每次我尝试构建APK文件以导出到android设备上时,Unity都会给我一条错误消息,说明它无法构建APK文件,并且我应该确保android sdk配置正确。然而,我已经通过Oracle或Android studio多次重新安装了最新的sdk,但我总是收到同样的错误消息。我可以在Unity编辑器中很好地测试游戏,但每次我尝试导出时都会遇到问题。它还在“外部工具”下的首选项中声明,我没有使用正确的android sdk工具和ndk工具,不过,就像我说的那样,我已经尝试安装正确的工具多次,甚至重新安装了所有工具,但我总是得到同样的错误。

这是我在Unity编辑器中打开项目时得到的错误消息:

DirectoryNotFoundException: Could not find a part of the path 'D:\Android\build-tools'.
System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].HandleError (System.Int32 hr, System.String path) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].CommonInit () (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.FileSystemEnumerableIterator`1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler`1[TSource] resultHandler, System.Boolean checkHost) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.Directory.InternalGetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.IO.Directory.GetDirectories (System.String path) (at <23c160f925be47d7a4fd083a3a62c920>:0)
UnityEditor.Android.AndroidSDKTools.FindLatestBuildTools () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidSDKTools.UpdateToolsDirectories () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidSDKTools..ctor (System.String sdkRoot) (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidSDKTools.CreateAndroidSDKTools (System.String rootDir) (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidSDKTools.GetInstance[T] (UnityEditor.Android.AndroidSDKTools+InstanceCreator creator) (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidSDKTools.GetInstance () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.SDKManager..ctor () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.SDKManager.GetInstance () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.Android.AndroidPreferenceWindowExtension.WritePreferences () (at <252f3c2244e6415190676e82842416b7>:0)
UnityEditor.PreferencesProvider.WritePreferences () (at C:/buildslave/unity/build/Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs:753)
UnityEditor.PreferencesProvider.ApplyChangesToPrefs (System.Boolean force) (at C:/buildslave/unity/build/Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs:472)
UnityEditor.PreferencesProvider.ShowExternalApplications (System.String searchContext) (at C:/buildslave/unity/build/Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs:347)
UnityEditor.PreferencesProvider.OnGUI (System.String searchContext, System.Action`1[T] drawAction) (at C:/buildslave/unity/build/Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs:298)
UnityEditor.PreferencesProvider+<CreateExternalToolsProvider>c__AnonStorey1.<>m__0 (System.String searchContext) (at C:/buildslave/unity/build/Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs:201)
UnityEditor.SettingsProvider.OnGUI (System.String searchContext) (at C:/buildslave/unity/build/Editor/Mono/Settings/SettingsProvider.cs:103)
UnityEditor.SettingsWindow.DrawControls () (at C:/buildslave/unity/build/Editor/Mono/Settings/SettingsWindow.cs:322)
UnityEditor.SettingsWindow.DrawSettingsPanel () (at C:/buildslave/unity/build/Editor/Mono/Settings/SettingsWindow.cs:313)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:298)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:483)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:466)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:447)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/Events/MouseCaptureDispatchingStrategy.cs:93)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:280)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:156)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:189)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:255)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
This is the error message I get after the apk build and run has failed:
CommandInvokationFailure: Unable to install APK to device. Please make sure the Android SDK is installed and is properly configured in the Editor. See the Console for more details.
    C:/Users/mauri/AppData/Local/Android/Sdk\platform-tools\adb.exe -s "2245120c5e0d7ece" install -r "C:\Users\mauri\Desktop\Ball Tap\ball tap.apk"

    stderr[
    adb: failed to install C:\Users\mauri\Desktop\Ball Tap\ball tap.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.BallTap.Momo signatures do not match previously installed version; ignoring!]
    ]
    stdout[
    Performing Streamed Install
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.ADB.RunInternal (System.String[] command, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.ADB.Run (System.String[] command, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidDevice.Exec (System.String[] command, System.String errorMsg) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidDevice.Install (System.String apkfile) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidDeploymentTargetsExtension+<UploadAPK>c__AnonStorey3.<>m__0 () (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidDeploymentTargetsExtension.UploadAPK (UnityEditor.Android.AndroidBuildProperties buildProperties, UnityEditor.Android.AndroidDevice device, UnityEditor.Android.AndroidDeploymentTargetsExtension+LaunchProgressTaskManager taskManager) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidDeploymentTargetsExtension+<LaunchBuildOnTarget>c__AnonStorey0.<>m__2 () (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.ProgressTaskManager.Run () (at C:/buildslave/unity/build/Editor/Mono/Utils/ProgressBarUtils.cs:71)
    UnityEditor.Android.AndroidDeploymentTargetsExtension.LaunchBuildOnTarget (UnityEditor.DeploymentTargets.IDeploymentTargetsMainThreadContext context, UnityEditor.BuildProperties buildProperties, UnityEditor.DeploymentTargets.DeploymentTargetId targetId, UnityEditor.ProgressHandler progressHandler) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.DeploymentTargets.DeploymentTargetManager.LaunchBuildOnTarget (UnityEditor.BuildProperties buildProperties, UnityEditor.DeploymentTargets.DeploymentTargetId targetId, UnityEditor.ProgressHandler progressHandler) (at C:/buildslave/unity/build/Editor/Mono/DeploymentTargets/DeploymentTargetManager.cs:45)
    UnityEditor.PostprocessBuildPlayer+<LaunchOnTargets>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:203)
    UnityEditor.ProgressTaskManager.Run () (at C:/buildslave/unity/build/Editor/Mono/Utils/ProgressBarUtils.cs:71)
    UnityEditor.PostprocessBuildPlayer.LaunchOnTargets (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, UnityEditor.Build.Reporting.BuildReport buildReport, System.Collections.Generic.List`1[T] launchTargets) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:222)
    UnityEditor.Android.PostProcessAndroidPlayer.Launch (UnityEditor.BuildTarget target, System.String installPath, UnityEditor.Build.Reporting.BuildReport report) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.LaunchPlayer (UnityEditor.Modules.BuildLaunchPlayerArgs args) (at <252f3c2244e6415190676e82842416b7>:0)
    UnityEditor.PostprocessBuildPlayer.Launch (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, System.String path, System.String productName, UnityEditor.BuildOptions options, UnityEditor.Build.Reporting.BuildReport buildReport) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:166)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

共有1个答案

琴献
2023-03-14

1/Android SDK

在您的第一个输出中,您的路径似乎没有正确设置。您检查过路径'D:\android\build-tools'存在吗?

通常,使用Android Studio的常规安装会将SDK安装到

在Unity中,您可以通过编辑->首选项->外部工具,并设置Android SDK路径在Unity中设置此路径。

2/Android SDK版本

确保您在Unity中针对的SDK版本(播放器设置->其他设置->最低API级别和目标API级别)与您使用Android Studio下载的SDK相同。

4/包名称和签名

您的第二个错误说‘签名不匹配以前安装的版本’。您可能已经在您的设备上安装了一个版本,并使用不同的密钥进行了签名。您需要完全删除设备上的应用程序来解决此问题。看这个帖子。

 类似资料:
  • 我试图在webGL中构建我的游戏,但我得到了这个错误 找不到文件“C:\users----\OneDrive\Documents\Endless\Runner\Temp\StagingArea\Data\Native\Build.bc” 我对unity和stackoverflow很陌生,所以不要对我太苛刻。

  • 错误消息: (无法完成安装,因为找不到一个或多个必需的项目。正在安装的软件:Cucumber Eclipse Feature 0.0.17.201704062133(Cucumber.Eclipse.Feature.Feature.Group 0.0.17.201704062133)缺少要求:Cucumber Editor 0.0.17.201704062133(Cucumber.Eclipse.

  • 1.这是我的代码 当我运行它时,(错误) internal/modules/cjs/loader.js:1080抛出新的ERR_REQUIRE_ESM(filename,parentPath,packageJsonPath);

  • 我想在原子中安装熊猫,但是当我运行时 我收到 我很困惑为什么,因为我肯定有熊猫下载(通过) 当我键入蟒蛇时 --版本我得到 < code>Python 2.7.16 :: Anaconda,Inc. 类似问题的其他答案表明,问题是熊猫被安装在不同版本的蟒蛇上。然而,当我跑步时 我明白了 如果熊猫下载到python 2.7,我运行的是python 2.7,我不明白为什么它在尝试安装时说找不到它。

  • 项目生成错误:org.kurento的父POM不可解析。tutorial:kurento-group-call:6.5.0:无法在https://repo.maven.apache.org/maven2中找到org.kurento.tutorial:kurento-tutorial:POM:6.5.0缓存在本地存储库中,将不会重新尝试解析,直到central的更新间隔已过或强制更新且“parent

  • 当我激活这个插件时,它会向我显示错误,我如何解决这个问题? 致命错误:未捕获错误:在C:\xampp\htdocs\www\real\wp content\plugins\realtyelite theme plugin\inc\vc函数中调用未定义的函数vc\u add\u shortcode\u param()。php:3堆栈跟踪:#0 C:\xampp\htdocs\www\real\wp