[SOLVED] Build Failed Il2cpp

I wanted to optimize the size of my .apk file by exporting the scene I needed and import it to a clean project. All was fine no errors found in my project but it failed to build.

I did some googling and found that I have to remove the il2cpp things in my library folder but it won’t work.
Any help will be appreciated. Thanks!

This failure occurs because the code in the project has extern methods in C#. 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.

For example, this in this project one function which causes this issue is named: UnityMC_Delegate_getEnabled

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. See this documentation for details about native plugins: Unity - Manual: Native plug-ins

  2. Remove the C# code which defines this extern method. You can do that with platform dependent compilation: Unity - Manual: Conditional compilation

Thanks for your help! I’m not sure which one to remove but you mentioned UnityMC_Delegate_getEnabled and then I googled it and I found this. He mentioned about the multipeer folder and it’s related to iOS so I did this to every scripts which has DllImport inside it.

But it gives me some error like below when I build it

Seems like it tries to compile but can’t find the code.
I also tried to just removed it. It build successfully but when I tried it, the screen is black but the system actually tracking the surface because the points showed up and I can tap it to show the object.

*EDIT
I changed to this and the errors gone.

But still black screen when I tried it.