You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity Android打包IL2CPP错误:无法解析Input.get_touches()方法

Unity Android构建IL2CPP错误:无法解析UnityEngine.Input.get_touches()方法

问题描述

构建Android版本时持续触发IL2CPP错误,核心提示无法解析UnityEngine.Touch[] UnityEngine.Input::get_touches()方法引用,已尝试重装Unity及部分SDK,问题仍未解决。

解决方案

  • 检查输入系统配置:如果使用Unity 2020及以上版本,前往Player Settings > Other Settings > Configuration,将Active Input Handling设置为Both或Old Input Manager,确保旧输入模块被启用。
  • 替换废弃API:搜索项目中所有调用Input.touches的代码,若项目已迁移到新输入系统(Input System Package),替换为Touchscreen.current.touches;若保留旧系统,确认代码调用无误。
  • 清理项目缓存:删除项目根目录下的Library、Temp文件夹,重启Unity后重新导入资源,再尝试构建。
  • 排查插件冲突:临时移除第三方插件,逐个重新添加并构建,排查是否有插件错误引用该API或与Unity版本不兼容。
  • 验证SDK/NDK配置:在Unity Preferences > External Tools中,确认Android SDK、NDK、JDK路径正确,且版本与当前Unity版本匹配(例如Unity 2022推荐NDK r25c)。

完整错误日志

Error: IL2CPP error (no further information about what managed code was being converted is available)
System.AggregateException: One or more errors occurred. (Found a method reference we cannot resolve to a method definition: UnityEngine.Touch[] UnityEngine.Input::get_touches())
 ---> System.InvalidOperationException: Found a method reference we cannot resolve to a method definition: UnityEngine.Touch[] UnityEngine.Input::get_touches()
    at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveMethodReference(TypeContext context, UnderConstructionMethodReferenceRepository repository, CecilSourcedAssemblyData assemblyData, MethodReference methodReference, Dictionary`2 mapping)
   at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveAssemblyMethodReferences(TypeContext context, UnderConstructionMethodReferenceRepository repository, CecilSourcedAssemblyData assemblyDef, ReadOnlyHashSet`1 methodReferences)
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass15_0.<ResolveReferences>b__0(CecilSourcedAssemblyData data)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass33_0`2.<ForEachWorker>b__0(Int32 i)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
   at Unity.IL2CPP.DataModel.BuildLogic.Utils.ParallelHelpers.ForEach[TSource](IEnumerable`1 source, Action`1 func, Boolean enableSerial)
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Build()
   at Unity.IL2CPP.Contexts.Components.DataModelComponent.Load(LoadSettings loadSettings, Boolean ownsTypeContext, Boolean ownsBuilder, DataModelBuilder& builder)
   at Unity.IL2CPP.AssemblyConversion.Phases.InitializePhase.Run(AssemblyConversionContext context)
   at Unity.IL2CPP.AssemblyConversion.Classic.ClassicConverter.Run(AssemblyConversionContext context)
   at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(AssemblyConversionInputData data, AssemblyConversionParameters parameters, AssemblyConversionInputDataForTopLevelAccess dataForTopLevel)

内容的提问来源于stack exchange,提问作者SDKPainIsSDKGain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 17:31:04