googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.22k stars 339 forks source link

[Bug] unexpected char: '\' when using project export #498

Closed andreimamlay closed 2 years ago

andreimamlay commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

  1. Install Firebase from .unitypackage
  2. Enable
    • Custom Main Gradle Template
    • Custom Launcher Gradle Template
    • Custom Gradle Properties Template
  3. Export project
  4. Open unityLibrary/build.gradle
  5. See incorrect path in local maven url

Please answer the following, if applicable:

100%

Caused by the following code in PlayServicesResolver.cs

// If "Export Gradle Project" setting is enabled, gradle project expects
// absolute path.
if (exportEnabled) {
    repoUri = String.Format("\"{0}\"",
                            Path.Combine(projectFileUri, repoPath));
}

For example, Path.Combine("file:///C:/Unity/TestGame", "Assets/GeneratedLocalRepo/Firebase/m2repository") produces file:///C:/Unity/TestGame\Assets/GeneratedLocalRepo/Firebase/m2repository

google-oss-bot commented 2 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

paulinon commented 2 years ago

Hi @andreimamlay,

Thanks for reporting this, @andreimamlay. Version 1.2.169 of the resolver has been released recently. Could you confirm if the issue persists using that version as well?

andreimamlay commented 2 years ago

Thank you for your time, @paulinon .

I have

  1. updated external dependency manager (using external-dependency-manager-1.2.169.unitypackage)
  2. forced resolve

and can confirm, that issue remains: incorrect path delimiter is inserted into maven.url configuration

In master branch the following code still remains and causes incorrect delimiter on windows platform https://github.com/googlesamples/unity-jar-resolver/blob/8d9505bfaf53468b4412c721d7eff875ec082ca1/source/AndroidResolver/src/PlayServicesResolver.cs#L2146-L2147

Changing said line to

repoUri = String.Format("\"{0}\"",
                        Path.Combine(projectFileUri, repoPath).Replace("\\", "/"));

would fix the problem on windows platform

paulinon commented 2 years ago

Thanks for the information, @andreimamlay. I was able to observe this behavior on a Windows platform as well.

I'll let the team know about this. That being said, I'll be marking this as a bug for now.

andreimamlay commented 2 years ago

There was a PR for this issue!

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

andreimamlay commented 2 years ago

@paulinon Could you please look again at this issue?

chkuang-g commented 2 years ago

https://github.com/googlesamples/unity-jar-resolver/pull/421 was merged. I am preparing a new release of EDM4U once I got another patch in.

If you need the patch soon, you can rebuild EDM4U using

# Build .unitypackage
./gradlew buildPlugin

# Build .tgz
./gradlew buildUPMPlugin