amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

Compatibility with Google Dependency Resolver #47

Closed felipefujioka closed 4 years ago

felipefujioka commented 4 years ago

As described in the unity plugin integration guide, in section 6 there is a known issue that causes aar and jar files associated with Amplitude to be removed from the unity project. The troubleshoot does not seem to work properly as adding a Dependency.xml file describing the android packages does not change the Resolver behavior.

Unity version: 2018.4.18f Google Dependency Resolver version: 1.2.153 Amplitude SDk version: 2.27.0

haoliu-amp commented 4 years ago

Hello, could you tell me what steps do you do when you're doing integration? And what errors you're seeing?

haoliu-amp commented 4 years ago

Also, thee Unity version our SDK is based on is: 2019.3.11f. Please try to update your Unity version too.

felipefujioka commented 4 years ago

Hi,

The steps we followed were:

The Unity version is kinda of mandatory right now, as the update to the 2019 version would be pretty expensive for the whole project.

haoliu-amp commented 4 years ago

Thanks for sharing. How's your XXXDependencies.xml look like?

felipefujioka commented 4 years ago

I created a Dependencies.xml file in Assets/Editor/Dependencies.xml, it looks like this.

<dependencies>
  <androidPackages>
    <repositories>
      <repository>https://repo.maven.apache.org/maven2</repository>
    </repositories>

    <androidPackage spec="com.amplitude:android-sdk:2.27.0">
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>

    <androidPackage spec="com.squareup.okhttp3:okhttp:4.2.2">
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>
  </androidPackages>

  <iosPods>

  </iosPods>
</dependencies>
haoliu-amp commented 4 years ago

Everything look alright. It should be there're some task which will clean up all the libraries in your project. Does your project depend on any other dependency management tool?

felipefujioka commented 4 years ago

We use Google Depency Resolver and Unity Package Manager. There are other third-party libraries that import AAR and JAR files that work just fine. I really can't find a reason why Amplitude's binaries would be removed like this. I will start a clean example project to see if it happens without other tools.

felipefujioka commented 4 years ago

Is there any architecture limitation in the aar targets?

felipefujioka commented 4 years ago

Just found out the error.

"Some users use unity-jar-resolver themselves. When they force resolve dependencies, it will clean up Amplitude related jars. For this case, what you would need to do is to declare those dependencies in your *Dependency.xml file."

In the integration guide that we followed in our first attempt indicated that the dependency file should be Dependency.xml not Dependencies.xml and that caused the confusion. The aar are not imported in the project and that is fine, because we are using a gradle build, and gradle will take care of the dependencies on the build process.

It might be good to fix the text in the integration guide though.

Thanks for the support!

haoliu-amp commented 4 years ago

Glad you figured it out. However I wonder why it's Dependency.xml for your case, since even google official doc said it's Dependencies.xml

https://github.com/googlesamples/unity-jar-resolver

felipefujioka commented 4 years ago

It is wrong on amplitude unity integration guide actually.

Screen Shot 2020-08-28 at 18 37 59

haoliu-amp commented 4 years ago

@felipefujioka Oh! Thank you for catching it! We've fixed it.