排查常见错误

本页介绍了如何诊断和修复常见错误。它根据错误代码和日志消息划分为不同的部分。

响应代码 400

Connecting to: https://performanceparameters.googleapis.com/v1/applications/...
TuningFork:Web: Response code: 400
TuningFork:Web: Response message: Bad

如果您的 API 密钥无效,就可能会收到此错误。请参阅启用 API 部分和配置插件部分。

响应代码 403

TuningFork:Web: Connecting to: https://performanceparameters.googleapis.com/v1/applications/...:generateTuningParameters
TuningFork:Web: Response code: 403
TuningFork:Web: Response message: Forbidden

如果您的 API 密钥未启用或您在限制 API 密钥时出错(例如,您使用了错误的证书或哈希值),就可能会收到此错误。请参阅启用 API

日志中显示“No parameters: no fidelity parameters”警告和“java.lang.NoSuchFieldError”

TuningFork:FPDownload: No parameters: no fidelity parameters
TuningFork: java.lang.NoSuchFieldError: no "[Landroid/content/pm/ApplicationInfo;" field "applicationInfo" in class "Landroid/content/pm/PackageInfo;" or its superclasses
TuningFork: Could not get fidelity params from server : err = 4

这些是无害警告,由 Tuning Fork 库在检查应用是否设置了可调试标志时发出。这些警告虽然详细具体,但是无害,并不代表库集成中出现问题。您可以忽略这些警告

多个 Google.Protobuf.dll 文件

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name
Google.Protobuf.dll included for the current platform.
Only one assembly with the same name is allowed per platform. Assembly paths: ...

Error: The imported type `Google.Protobuf.IMessage<T>' is defined multiple times

如果您的项目包含多个 Google.Protobuf.dll 文件,您可能会收到其中一种错误。如需消除此冲突,请移除一个 .dll 文件。

尝试调用方法 …,对此未生成预先 (AOT) 代码

ExecutionEngineException: Attempting to call method 'Google.Protobuf.Reflection.ReflectionUtil+ReflectionHelper' ... for which no ahead of time (AOT) code was generated.

在部分版本的 Unity 上您可以查看此错误。如果 AOT 编译器没有为常规方法生成代码,会出现此错误。如需了解如何强制生成必需的代码,请参阅预先编译 (AOT) 部分。

命名空间“Google”中不存在类型名称或命名空间名称“Protobuf”

The type or namespace name `Protobuf' does not exist in the namespace `Google'. Are you missing an assembly reference?

确保您的项目使用的是 .NET 4.x。勾选 Player Settings > Other Settings > Configuration > Scripting Runtime Version

LoadingSceneTracker.cs:找不到类型名称或命名空间名称“FidelityParams”

LoadingSceneTracker.cs: The type or namespace name 'FidelityParams' could not be found (are you missing a using directive or an assembly reference?)
LoadingSceneTracker.cs: The type or namespace name 'Annotation' could not be found (are you missing a using directive or an assembly reference?)

Player Settings > Scripting Define Symbols 中移除 ANDROID_PERFORMANCE_TUNER_UTILITIES