Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
16.93k stars 4.14k forks source link

Android build broken #3167

Closed whalefood closed 4 years ago

whalefood commented 4 years ago

A project with mlagents won't compile when the platform is switched to android. Getting a bunch of reference errors:

"The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?)'

Looks like this is related to the google protobuf library. You can see the issue just in the example project.

surfnerd commented 4 years ago

Hi @whalefood, It looks like this DLL is included with Barracuda and is not available for those platforms according to their configuration in their package. I have assigned @mantasp for him to take a look.

surfnerd commented 4 years ago

I believe this is related to #3125, which I have mistakenly closed. I will reopen it.

whalefood commented 4 years ago

Thanks for taking a look

surfnerd commented 4 years ago

You may be able to copy it, and only include it for android.

surfnerd commented 4 years ago

So, I just did a sort of hacky thing and got it to work. You can edit the Google.Protobuf.dll.meta file. Flip all of the Android platform enabled flags to 1. Then you should be able to build for Android.

surfnerd commented 4 years ago

Screen Shot 2020-01-06 at 2 52 45 PM

This is where I found that file. You can open the Google.Protobuf.dll.meta file with a text editor.

Modify the line

        Exclude Android: 1

to

        Exclude Android: 0

and then modify

  - first:
      Android: Android
    second:
      enabled: 0
      settings:
        CPU: ARMv7

to

      Android: Android
    second:
      enabled: 1
      settings:
        CPU: ARMv7
surfnerd commented 4 years ago

The same could be done for iOS

whalefood commented 4 years ago

Good to know. Thanks!

anttir commented 4 years ago

image This fix worked for me, thank you! Just remember to Reimport the package after making the changes.

akira675 commented 4 years ago

Is there a resolution for this issue that will work for Cloud Builds?

JoRouss commented 4 years ago

In unity 2019.3.3f1, ml-agent 0.14.1, I just had to update the Barracuda package from version 0.5.0 to version 0.6.0 and I was able to build without the error.

chriselion commented 4 years ago

@JoRouss Good point, that was something that Barracuda addressed in the 0.6.0 release:

Fix: enabled Google Protobuf for all platforms as ML Agents rely on this package. Fixes building ML Agents on non-desktop platforms.

(from https://github.com/Unity-Technologies/barracuda-release/blob/release/0.6.0/CHANGELOG.md#060---2020-02-14)

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.