Failing to build: Cannot convert something to int32_t

Have a larger project that has been building fine for years on several platforms (Android, iOS, Win64). Runs perfectly in editor.

But now when I try to build for Android, I get this single error and I’m really at a loss for where to look… googling comes up with a few similar hits but not the same problem.

Building Library\Bee\artifacts\Android\d8kzr\54h5eddtozdg.o failed with output:
D:\project\Library\Bee\artifacts\Android\il2cppOutput\cpp\GenericMethods__18.cpp(36510,9): error: cannot convert ‘ToHit_t3AF3ABD05F25D743CB5F55EF5822A7984E3C71CA’ to ‘int32_t’ (aka ‘int’) without a conversion operator
return static_cast<int32_t>(___0_instance);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Unity v.2022.3.7f1
IL2CPP
using Addressables with a successful asset build if that matters.

The only clue I can come up with from that message is ‘ToHit_’ which is a prefix used on a few string variables in generated code from (the amazing) BGDatabase plugin package, but that big gnarly string afterwards is not coming up in any searches of my solution.

It all previously worked in several older versions of Unity and older versions of lots of plugins/package combos.

Anyone else seen this or have any ideas? Suggestions or spitball ideas appreciated!

This looks like it is a bug in IL2CPP. Either that, or the input IL code in some assembly in this project is not valid.

Can you submit a bug report to Unity with a project that causes this issue? Unity QA: Building quality with passion

I’ve been trying to create a simpler project that reproduces the issue for that, but having no luck so far. So it must be some tricky combo of assemblies/plugins/packages… the project is fairly complicated at this point and weeding out what is causing it manually without debugging hooks into the build process itself is going to be very difficult. I’m currently trying to send a report with the full project attached, but I think it’s maybe too big (currently just under 10GB)? I’ll let it spin all night and hopefully by the morning it might go through.

Looks like it went through, Case IN-52744

1 Like

Thanks, we will investigate this!

Just updated to Unity 2022.3.8f1 and confirmed error still occurs on Android builds.

Update: Can confirm it builds with no errors on other target platforms (Windows and iOS).

Still occurs in 2022.3.9f1. Also discovered it occurs when trying to package a build using the iOS Builder package from the asset store (which in turn uses the editor’s il2cpp compiler).

I’ve tried swapping in the il2cpp compiler builds from previous editor installs (2021.x and 2020.x) both fail with the same error.

So actually right now, I am unable to deploy my latest build to either Android or iOS for almost 4 weeks. :frowning: Any word on progress here?

5 weeks of development lost now. I’ve painstakingly recreated my entire project into an empty project as far as I can. Added packages one by one, added my code in, recreated the same BGDatabase (the only thing that mentions “ToHit” in a string form anywhere in the project), etc. Still can’t narrow down what part of my project is causing this and I have no way to get extra info from the il2cpp compiler. No apparent movement on Unity’s side after it being a confirmed bug in the complier. Any suggestion of things to try would be appreciated.

I’m at the point where I’d have to recreate all the backend services and point them at a new project to move forward. And there’s no guarantee I won’t hit this blocker again.

Given the knife in the back we’re all taking from Unity’s leadership on ToS and pricing, I guess I’d have been better off spending the last 5 weeks starting to port to Unreal, as this will be my last project in Unity as things stand. Really frustrated right now.

OMG. I just switched the il2cpp Code Generation configuration to “Faster (smaller) builds” from “Faster Runtime” and it worked.

5 weeks lost.

I also encountered the same problem,when I build android apk
build android error in Unity v.2021.3.16f1、Unity v.2021.3.33f1、Unity v.2021.3.35f1、Unity v.2021.3.36f1
IL2CPP
Note:Can confirm it builds with no errors on other target platforms (Windows and iOS).

console log

Building Library\Bee\artifacts\Android\d8kzr\cq9sc0u8cljx.o failed with output:
D:\Work\Projects\Project_HybridCLR\Lobby\Library\Bee\artifacts\Android\il2cppOutput\cpp\GenericMethods__21.cpp(32582,9): error: cannot convert ‘CardType_t3EEF93B32FA6FE4ADE49258DBD1581738DF3C25E’ to ‘int32_t’ (aka ‘int’) without a conversion operator
return static_cast<int32_t>(___0_instance);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\Work\Projects\Project_HybridCLR\Lobby\Library\Bee\artifacts\Android\il2cppOutput\cpp\GenericMethods__21.cpp(32587,9): error: cannot convert ‘HallID_tA02DAEDC8C11AF433A1444B18A2C4441C479A5CC’ to ‘int32_t’ (aka ‘int’) without a conversion operator
return static_cast<int32_t>(___0_instance);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

===============================================================================

CardType_
HallID_
is enum type form anywhere in the project~

This sounds like a bug with IL2CPP. Can you submit a bug report with a project that causes this issue?