unity-jar-resolver icon indicating copy to clipboard operation
unity-jar-resolver copied to clipboard

Gradle failed to fetch dependencies (4.2.0)

Open lightray1 opened this issue 9 years ago • 16 comments

Gradle failed to fetch dependencies.

Failed to run 'Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle --no-daemon "-PANDROID_HOME=c:\Users\Luca\AppData\Local\Android\android-sdk" "-PTARGET_DIR=D:\RavensDiary\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///D:/RavensDiary/Assets/Firebase/m2repository" "-PPACKAGES_TO_COPY=com.google.firebase:firebase-analytics:11.4.0;com.google.firebase:firebase-core:11.4.0;com.google.firebase:firebase-analytics-unity:4.2.0;com.google.android.gms:play-services-base:11.4.0;com.google.firebase:firebase-common:11.4.0;com.google.firebase:firebase-app-unity:4.2.0"' stdout:

This Gradle script performs the following:

  • Adds Android maven repositories to search locations for artifacts.
  • Adds user specified maven repositories to search locations for artifacts.
  • Copies specified set of maven artifacts to the specified output directory.
  • Displays the set of files copied into the output directory.
  • Displays any packages that were not found.

./gradlew -b D:\RavensDiary\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle
"-PMAVEN_REPOS=[semicolon separated list of repo URIs]"
"-PPACKAGES_TO_COPY=[semicolon separated list of maven artifacts]"
-PTARGET_DIR=[target directory]

ANDROID_HOME (required env var, system property or project property): Required environment variable, system property or project project that specifies the install location of the Android SDK. MAVEN_REPOS (optional project property): Optional property which adds to the list of Maven repositories to search. This is a semicolon separated list of URIs e.g "-PMAVEN_REPOS=http://some.repos.com;file:///some/other/path" Since this property semicolon separated it needs to be quoted correctly when specified via some command line shells. PACKAGES_TO_COPY (required project property): Semicolon separated list of Maven artifact specifications. This will result in the script attempting to download the set of artifacts to TARGET_DIR. Specified artifacts that are not copied to the target directory are logged to the standard output stream. e.g "-PPACKAGES_TO_COPY=com.android.support:support-compat:26.0.1;com.android.support:support-core-utils:26.0.1" Since this property semicolon separated it needs to be quoted correctly when specified via some command line shells. TARGET_DIR (required project property): Directory to copy artifacts to. e.g -PTARGET_DIR=some/directory/to/copy/to

stderr: Project property PACKAGES_TO_COPY must be specified.

exit code: 1

UnityEngine.Debug:LogError(Object) GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel) Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean) GooglePlayServices.c__AnonStorey14:<>m__20(Result) GooglePlayServices.c__AnonStorey15:<>m__2B() GooglePlayServices.PlayServicesResolver:PumpUpdateQueue() UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

lightray1 avatar Oct 13 '17 09:10 lightray1

@lightray1 this is very confusing. Looks like you're running on Windows, download_artifacts.gradle appears to be complaining about -PPACKAGES_TO_COPY being missing though from your log it's on the command line.

I'm wondering how to reproduce this. Could you share your Unity version, Windows version and anything else you could imagine may be related to this?

Cheers, Stewart

stewartmiles avatar Oct 13 '17 17:10 stewartmiles

From a project I was using to try to diagnose errors with #73 with verbose logging enabled I end up with the following using Unity 2017.1 on Windows 7 enterprise SP1.

Command completed: Successfully executed 'Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle --no-daemon "-PANDROID_HOME=C:/dev/adt/sdk" "-PTARGET_DIR=C:\__CameraOpen\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///C:/__CameraOpen/Assets/Firebase/m2repository" "-PPACKAGES_TO_COPY=com.google.firebase:firebase-analytics:11.4.0;com.google.firebase:firebase-core:11.4.0;com.google.firebase:firebase-analytics-unity:4.2.0;com.google.android.gms:play-services-base:11.4.0;com.google.firebase:firebase-common:11.4.0;com.google.firebase:firebase-app-unity:4.2.0"'

A few things to check / try:

  • The Gradle wrapper will not be updated if you don't close / reopen Unity. We store it in the Temp directory and don't update it unless Unity is restarted or the directory is deleted.
  • Have you customized your Gradle environment? https://docs.gradle.org/current/userguide/build_environment.html if so that could be picked up by the wrapper.

https://github.com/googlesamples/unity-jar-resolver/blob/master/source/PlayServicesResolver/scripts/download_artifacts.gradle#L190 is the code that is tripping up. I'm not sure why your command line would result in this property not being set at the moment.

Cheers, Stewart

stewartmiles avatar Oct 13 '17 17:10 stewartmiles

I tried reproducing by mounting a directory as D: drive on my machine then running the command line you pasted with the Firebase Unity 4.2.0 SDK...

C:\__CameraOpen>Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle --no-daemon "-PANDROID_HOME=c:\Users\Luca\AppData\Local\Android\android-sdk" "-PTARGET_DIR=D:\RavensDiary\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///D:/RavensDiary/Assets/Firebase/m2repository" "-PPACKAGES_TO_COPY=com.google.firebase:firebase-analytics:11.4.0;com.google.firebase:firebase-core:11.4.0;com.google.firebase:firebase-analytics-unity:4.2.0;com.google.android.gms:play-services-base:11.4.0;com.google.firebase:firebase-common:11.4.0;com.google.firebase:firebase-app-unity:4.2.0"
:copyPackages
Copied artifacts:
firebase-analytics-11.4.0.aar
firebase-core-11.4.0.aar
play-services-base-11.4.0.aar
firebase-common-11.4.0.aar
play-services-basement-11.4.0.aar
firebase-analytics-impl-11.4.0.aar
play-services-tasks-11.4.0.aar
firebase-iid-11.4.0.aar
support-v4-25.2.0.aar
support-compat-25.2.0.aar
support-media-compat-25.2.0.aar
support-core-utils-25.2.0.aar
support-core-ui-25.2.0.aar
support-fragment-25.2.0.aar
support-annotations-25.2.0.jar


BUILD SUCCESSFUL

Total time: 6.467 secs

Seemed to work :/

stewartmiles avatar Oct 13 '17 17:10 stewartmiles

Hi stewartmiles, I'm using Unity 2017.11f1 on Windows 10 Pro. I haven't edited my Gradle environment configuration, and I've restarted Unity many times during my attempts to solve the problem.

After my first post, I've tried to past the command into the prompt too, and removing the quotes Gradle seems to work. But then, while compiling the Unity project, appears another error about the absence of a java class, so I'm not sure if the problem depends on the resolver or on the Firebase libraries ... I'm very confused!

lightray1 avatar Oct 13 '17 18:10 lightray1

@lightray1 what happens if you delete the files produced by the resolver from Assets/Plugins/Android i.e

firebase-analytics-11.4.0.aar
firebase-core-11.4.0.aar
play-services-base-11.4.0.aar
firebase-common-11.4.0.aar
play-services-basement-11.4.0.aar
firebase-analytics-impl-11.4.0.aar
play-services-tasks-11.4.0.aar
firebase-iid-11.4.0.aar
support-v4-25.2.0.aar
support-compat-25.2.0.aar
support-media-compat-25.2.0.aar
support-core-utils-25.2.0.aar
support-core-ui-25.2.0.aar
support-fragment-25.2.0.aar
support-annotations-25.2.0.jar

Then select the Assets > Play Services Resolver > Android Resolver > Force Resolution menu option? I would assume the same result.

Are you able to reproduce the problem with one of our sample projects e.g https://github.com/firebase/quickstart-unity/tree/master/analytics/testapp ?

Trying to narrow down whether this is a project specific issue. Perhaps Windows 10!?

stewartmiles avatar Oct 13 '17 18:10 stewartmiles

@stewartmiles I've tried, I had the same problem on the analytics testapp during the forced resolution.

lightray1 avatar Oct 13 '17 19:10 lightray1

Update: I've installed the same Unity version, Android SDK (copy-pasted) and JDK, on a Windows 7 VM, and the resolution works! BTW I don't think I'm the only W10 user of Unity + Firebase, so I'm still confused. As workaround, I'm using the VM to make the resolution, but it's very impratical.

lightray1 avatar Oct 14 '17 11:10 lightray1

@lightray1 thanks for narrowing this down to a Windows 10 issue. We'll put a Win10 box together to figure out what's going on here.

stewartmiles avatar Oct 16 '17 14:10 stewartmiles

@lightray1 we tried and failed to reproduce the failure on a Windows 10 enterprise machine. We did run across one internal user who had the openjdk installed which caused Gradle to fail to parse the Java version string which caused a failure which is different to what you reported.

So I have a patch lined up that uses gradle.properties and command line arguments to send project properties to the download_artifacts.gradle script. This may resolve the issue on Windows 10 where it looks like Gradle isn't parsing properties from command line arguments correctly. Will post an update when it's on github.

stewartmiles avatar Oct 18 '17 21:10 stewartmiles

@lightray1 I just pushed 1.2.57 with a patch that generates gradle.properties to workaround the problems passing arguments to command line applications f21962293581556d35ac3f5683a779fae4bd7fb2 . Please give it a try on your problematic machine and let me know.

stewartmiles avatar Oct 19 '17 01:10 stewartmiles

Yes, it works! Thank you so much, I can finally put aside the annoying virtual machine!

lightray1 avatar Oct 19 '17 16:10 lightray1

Awesome, we'll roll this into the next Firebase release.

stewartmiles avatar Oct 19 '17 16:10 stewartmiles

The fix for this is released in Firebase 4.2.1 https://firebase.google.com/support/release-notes/unity#4.2.1.

johnb003 avatar Oct 23 '17 17:10 johnb003

@stewartmiles @johnb003 I still have this problem. I use https://github.com/firebase/quickstart-unity/tree/master/analytics/testapp but not change any things I very confused please help me. I send question to Stack Overflow With all details and image https://stackoverflow.com/questions/51628906/android-firebase-unity-have-error-gradle-failed-to-fetch-dependencies-and-resol all my software is update and work fine but with firebase have problem. My software config :

Firebase Unity SDK 5.2.0
Android NDK r13b
Android SDK Full Update
JDK 8u181
JRE 8u181
Windows 7
Unity 2018.2.1f1

Error in Unity:

Gradle failed to fetch dependencies.

Failed to run 'C:\Users\Arman\Desktop\TestFireBaseUnity\Temp\PlayServicesResolverGradle\gradlew.bat -b "C:\Users\Arman\Desktop\TestFireBaseUnity\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" --no-daemon "-PANDROID_HOME=C:/Android_SDK" "-PTARGET_DIR=C:\Users\Arman\Desktop\TestFireBaseUnity\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///C:/Users/Arman/Desktop/TestFireBaseUnity/Assets/Firebase/m2repository" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-base:15.0.1;com.google.firebase:firebase-common:16.0.0;com.google.firebase:firebase-core:16.0.1;com.google.firebase:firebase-app-unity:5.2.0;com.google.firebase:firebase-iid:16.2.0;com.google.firebase:firebase-messaging:17.1.0;com.google.firebase:firebase-messaging-unity:5.2.0"'
stdout:
Unzipping C:\Users\Arman\.gradle\wrapper\dists\gradle-4.2.1-bin\dajvke9o8kmaxbu0kc5gcgeju\gradle-4.2.1-bin.zip to C:\Users\Arman\.gradle\wrapper\dists\gradle-4.2.1-bin\dajvke9o8kmaxbu0kc5gcgeju

stderr:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
	at java.util.zip.ZipFile.<init>(ZipFile.java:169)
	at org.gradle.wrapper.Install.unzip(Install.java:215)
	at org.gradle.wrapper.Install.access$600(Install.java:27)
	at org.gradle.wrapper.Install$1.call(Install.java:75)
	at org.gradle.wrapper.Install$1.call(Install.java:48)
	at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
	at org.gradle.wrapper.Install.createDist(Install.java:48)
	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

exit code: 1

UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__0(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey1:<>m__0()
Google.RunOnMainThread:ExecuteNext()
Google.RunOnMainThread:ExecuteAll()
Google.RunOnMainThread:Run(Action, Boolean)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__1(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__2(Result)
GooglePlayServices.ProgressReporter:SignalComplete()
GooglePlayServices.ProgressReporter:Update(CommandLineDialog)
GooglePlayServices.CommandLineDialog:Update()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Resolution failed
Failed to fetch the following dependencies:
com.google.android.gms:play-services-base:15.0.1
com.google.firebase:firebase-common:16.0.0
com.google.firebase:firebase-core:16.0.1
com.google.firebase:firebase-app-unity:5.2.0
com.google.firebase:firebase-iid:16.2.0
com.google.firebase:firebase-messaging:17.1.0
com.google.firebase:firebase-messaging-unity:5.2.0


UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
GooglePlayServices.<DoResolutionUnsafe>c__AnonStorey4:<>m__1(List`1)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__0(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey1:<>m__0()
Google.RunOnMainThread:ExecuteNext()
Google.RunOnMainThread:ExecuteAll()
Google.RunOnMainThread:Run(Action, Boolean)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__1(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey0:<>m__2(Result)
GooglePlayServices.ProgressReporter:SignalComplete()
GooglePlayServices.ProgressReporter:Update(CommandLineDialog)
GooglePlayServices.CommandLineDialog:Update()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Error in Device Monitor:

DllNotFoundException: FirebaseCppApp-5.2.0
at (wrapper managed-to-native) Firebase.AppUtilPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_AppUtil (Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: An exception was thrown by the type initialize

as0o0o0 avatar Aug 01 '18 10:08 as0o0o0

@as0o0o0

Absolutely identical error and output both on unity and device monitor, scratching my head for days now, only difference is the unity version, i got the 2018 1.6... any idea please! :) have a nice day spago

*update Fixed: Well, a workaround actually, but whatever --disable the unity.task dll in parse/plugin and enable parse/plugin/dotnet45 and reimport dll --if this was already like this just switch runtime versione in the player settings from 3.5 to 4 --if it was already 4 switch back to 3.5 and then back to 4

Worked for me ;)

SpaghettiCode4Ever avatar Aug 05 '18 08:08 SpaghettiCode4Ever

@SpaghettiCode4Ever thanks buddy

SOLVED MY PROBLEM My problem was the version of the Android SDK build-tools and tools version.

The Android SDK was updated, but in the build-tools directory , there was an old directory called "android-4.2.2" that solved the problem by removing it.

I also downgraded the Android SDK tools version from 26.1.1 to 25.2.5

as0o0o0 avatar Aug 09 '18 09:08 as0o0o0