简体   繁体   English

Unity 2017.4.34f1 无法使用 IL2CPP 构建 APK

[英]Unity 2017.4.34f1 Cant build APK using IL2CPP

I try to build my project using Unity 2017.4.34f1 , because Google now need both 32 & 64 bit, so i choose IL2CPP .我尝试使用Unity 2017.4.34f1构建我的项目,因为 Google 现在需要 32 位和 64 位,所以我选择IL2CPP

For Android NDK, I use r13b对于 Android NDK,我使用r13b

However, build failed and I get below error ( summary ):但是,构建失败并且出现以下错误(摘要):

Exception: /Applications/Unity/Hub/Editor/2017.4.34f1/Unity.app/Contents/il2cpp/build/il2cpp.exe did not run properly!异常:/Applications/Unity/Hub/Editor/2017.4.34f1/Unity.app/Contents/il2cpp/build/il2cpp.exe 没有正常运行!

This failure occurs because the code in the project has extern methods in C#.出现这种失败是因为项目中的代码在C#中有extern方法。 Methods marked as extern with a the [Dllimport("__Internal")] attribute must be present in a native library that is linked with the Unity player when building with the IL2CPP scripting backend.使用 IL2CPP 脚本后端构建时,使用[Dllimport("__Internal")]属性标记为 extern 的方法必须存在于与 Unity 播放器链接的本机库中。

For example, this in this project one function which causes this issue is named: activateApp例如,在这个项目中,导致这个问题的一个函数被命名为: activateApp

You have two options:你有两个选择:

  1. Build a native library with all of the methods marked as extern with the [Dllimport("__Internal")] attribute for the target platform and architecture of the player.为播放器的目标平台和体系结构构建一个本机库,其中所有方法都标记为带有 [Dllimport("__Internal")] 属性的 extern。 See this documentation for details about native plugins: https://docs.unity3d.com/Manual/NativePlugins.html有关本机插件的详细信息,请参阅此文档: https ://docs.unity3d.com/Manual/NativePlugins.html

  2. Remove the C# code which defines this extern method.删除定义此外部方法的 C# 代码。 You can do that with platform dependent compilation: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html您可以通过依赖于平台的编译来做到这一点: https ://docs.unity3d.com/Manual/PlatformDependentCompilation.html

In this case specifically, it looks like the error comes from the Facebook SDK.具体来说,在这种情况下,错误似乎来自 Facebook SDK。 See if there is a newer Facebook SDK available - I believe this may have been corrected.查看是否有更新的 Facebook SDK 可用 - 我相信这可能已得到纠正。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM