Gradle failed to fetch dependencies | Resolution failed -in Unity3d - unity3d

This error occurs when I try to build&Run my game with Unity. I've also imported the GooglePlayServices/ads from here and also have the latest android sdk and jdk-8u144.
Here is the Error Log:
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/rfkha/AppData/Local/Android/sdk1" "- PTARGET_DIR=C:\Users\rfkha\Documents\Space Shooter\Assets\Plugins\Android" "- PMAVEN_REPOS=https://maven.google.com" "- PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:11.2.2"'
stdout:
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
stderr:
exit code: 1
UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
2nd Error:
Resolution failed
Failed to fetch the following dependencies:
com.google.android.gms:play-services-ads:11.2.2
UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
GooglePlayServices.<DoResolutionUnsafe>c__AnonStorey17:<>m__26(List`1)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

add JAVA_HOME to your environment variables for mine it is C:\Program Files\Java\jdk1.8.0_144 It worked for me maybe it will for you.

For me latest Google Play Services resolver cannot copy library play-services-ads.aar to /Assets/Plugins/Android. I have to copy it manually from sdk folder:
sdk\extras\google\m2repository\com\google\android\gms\play-services-ads
to my
/Assets/Plugins/Android folder.

Delete all Google AdS files from the Asset Name folder and re-import the Google AdS package.
Or
-Right click on "my computer" and go to properties.
-Go to the Advanced tab
-Click on the Environmental Variables button
-Find the JAVA_HOME variable under System Variables
-Change the value to wherever this file actually exists for you. (for me it was C:\Program Files\Java\jdk-10)
-Restart Unity

I had to add the Jdk address as given in unity->Edit->preferences
and paste the address in the JAVA_HOME variable value.
then I restart my system and it fetched all the android dependencies and started working.
if it does not start fetching on its own you can force resolve the android dependencies.Assets->ExternalDependencyManager->AndroidResolver->force Resolve.

Related

Gradle get wrong JAVA_HOME value

I try to run "ionic capacitor run". It is an Ionic 5 Capacitor proejct.
Java installed in c:\Program Files\Java\jdk1.8.0_311 and c:\Program Files\Java\jre1.8.0_311.
When I set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_311\bin I have got this error:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_311\bin
[capacitor] Please set the JAVA_HOME variable in your environment to match the
[capacitor] location of your Java installation.
When I set to C:\Program Files\Java\jdk1.8.0_311 (without \bin suffix) I have got this error:
[capacitor] FAILURE: Build failed with an exception.
[capacitor]
[capacitor] * What went wrong:
[capacitor] Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jdk-16.0.2
The 1.16 version was installed earlier but I uninstalled and installed 1.17.
Finally I end up with 1.8 because I have got an Ionic 4 cordova project which not work with Java 1.17.
I uninstalled/reinstalled Java, set environment variables in users and/or system settings and restarted windows several times, but I still don't know where this C:\Program Files\Java\jdk-16.0.2 value come from.
My Ionic4 (cordova) project works fine, can find the right value of JAVA_HOME and can build the app.
First start with echo %JAVA_HOME% and echo %PATH% , to see what your current Java JDK is set too in the environment and the path.
When setting the environment value use C:\Program Files\Java\jdk1.8.0_311 don't add the \bin that you include in the path, Set the path C:\Program Files\Java\jdk1.8.0_311\bin or %JAVA_HOME%\bin, Start with the first one to test.
! Important referring to the path on System variables ,Don't confuse it for the User variables path
Once you have changed the values for both environment value and path save and apply, open a new terminal for the new changes to take effect , Then run echo %JAVA_HOME% and echo %PATH% again if correct.

Flutter Gradle task assembleDebug failed with exit code 1 zip END header not found

Hello I am new to Flutter I have setup flutter with android studio 4.2.1, and every thing is fine. When I try to run it; it show me following error
I see too much questions but it is not helpfull for me
flutter doctor run no issue found
Hers is doctor result
Here is my enviroment variable
can any one guide me how can I run the flutter. I am lunching it in a chrome
exception in thread "main" java.util.zip.ZipException: zip END header not found at
java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1567) at
java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1462) at
java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1469) at
java.base/java.util.zip.ZipFile$Source.(ZipFile.java:1274) at
java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1237) at
java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:727)
at
java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:844)
at java.base/java.util.zip.ZipFile.(ZipFile.java:247) at
java.base/java.util.zip.ZipFile.(ZipFile.java:177) at
java.base/java.util.zip.ZipFile.(ZipFile.java:191) at
org.gradle.wrapper.Install.unzip(Install.java:214) at
org.gradle.wrapper.Install.access$600(Install.java:27) at
org.gradle.wrapper.Install$1.call(Install.java:74) at
org.gradle.wrapper.Install$1.call(Install.java:48) at
org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48) at
org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1
I recently Solved this problem.
This Problem came from gradle file is corrupted in my system.
I'm using Linux so this steps almost same in windows also. This answer is for any gradle version.
Open File Manager:
enable Show hidden folder from top menu bar.
You may find this location : .gradle>wrapper>dists.
In Linux: Home > .gradle > wrapper > dists.
In Windows: C:>Users>{PC Name}>.gradle>wrapper>dists
Method 1
Go inside gradle-6.5-all > dists > 2oz4ud9k3tuxjg84bbf55q0tn. '2oz4ud9k3tuxjg84bbf55q0tn' may be different in your PC.
Delete all files in that folder and download required file manually: https://downloads.gradle-dn.com/distributions/gradle-6.5-all.zip
after download paste freshly downloaded zip file in that folder.
Run your project flutter run -v
Method 2
Try this if you have fast & stable internet connection.
Delete that gradle-6.5-all folder.
Open project in VS code or Android Studio and open terminal.
Run this command flutter run -v
Method 3
Flutter Doctor will give right result.
Open Android Studio
Create new flutter project
Click on Tools > flutter >Flutter for editing in android studio
and wait, flutter doctor takes time to identify problem.
Use this link for download gradle file.
Replace 6.5 with your gradle version.
https://downloads.gradle-dn.com/distributions/gradle-6.5-all.zip
I hope this answer helpful for you.
Please use the below command
1.Mac User :
rm -rf ~/.gradle
2.Windows User :
remove the .gradle file
.gradle file location -> C:\Users\myUser
I solve this error by updating the gradle plugin/version. I have as part of my configuration:
Windows 10
Android Studio 4.2.1
Java 11: Android Studio 4.2.1 don't have support for JDK 16, so, I installed JDK 11, and configured the AS (how to change the jdk in AS) to use this older JDK
Gradle 7.0.1
By default, when you create a new Flutter project, the IDE created it with basic standard configurations, so you have to change this configs to fit your current config. For that, you need to update the gradle config in the flutter project, as follow:
in android/gradle/build.gradle file: update the gradle plugin to 4.2.0 in the dependencies section, like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
//more dependencies
}
in android/gradle/wrapper/gradle-wrapper.properties file: update the gradle version, in this case I have the 7.0.1, feel free to use another one, like this
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-all.zip
//more attributes
After you change the gradle config, run this commands in your project:
flutter clean : clean the project
flutter pub get : update your dependencies
flutter run : run the project. Now it must work, at least it work for me
I faced the same problem in VSCode when I wanted to run the Flutter app I got that error, so after lots of debugging and research, I found the solution. it's pretty easy, just follow these steps:
In windows 10:
1. Open flutter project in a Text-Editor like VSCode.
2. Open android -> gradle -> wrapper -> gradle-wrapper.properties
3. You will find "gradle-6.7.1.all.zip" inside gradle-wrapper folder
4. Go to this path: C:\Users\your-user
5. Then go to the wrapper->dists and find "gradle-6.7.1.all" folder
5. Delete this folder.
6. Then come to VSCode and open Terminal.
7. Please make sure that you have stable internet connection then type this command in terminal
8. flutter run
I hope this solution can help you!
I solve this error by deleting the .gradle folder.
This location is gradle folder
In Windows: C:> Users> {PC Name}>. Gradle
After deleting this folder, you only need to run the application again in Android Studio. At this point, Android Studio starts downloading the deleted folder automatically.
enter image description here
This error is caused by corrupted gradle files, this is either due to incomplete downloads due to network issues. To solve it easily download the gradle zipped file from https://downloads.gradle-dn.com/distributions/gradle-6.7-all.zip and paste on the .gradle directory as shown below if you are on linux
enter image description here
I try all method but it did not work for me so i decided to location the gradle-wrapper.properties in the andriod folder then i change the distribution gradle link to a more recent gradle link.
Welcome SO.
Java 16/latest version is not fully compatible with the Gradle 6 at this moment. Try to use java 11 or 8, it will resolve your issue.

"Flutter run" giving error in Mac OS once I change in pubpec.yaml file

Please check below error, I am getting below error once I did some changes in "pubspec.yaml" file.
When I initial setup the project It works, as I did some changes then I am getting below error.
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart
side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
Running Xcode build...
Xcode build done. 2.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
note: Using new build system
note: Planning build
note: Constructing build description
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
error: /Users/neeteshkeshari/Projects/development/song_app/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Looking forward for kind response.
You'll need to install the changes made to the pubspec file, you can do this by following either of the 3 options:
Install it
From the terminal: Run flutter pub get.
OR From Android Studio
Click Packages get in the action ribbon at the top of
pubspec.yaml.
OR From VS Code:
Click Get Packages located in right side
of the action ribbon at the top of pubspec.yaml.
Then run the following in the terminal:
sudo gem install cocoapods
terminal:
flutter pub get
or if you are using VSCode with the Flutter extension, you can simply do:
CMD + S on your pubspec.yaml file (saving the file automatically calls flutter pub get)
if the error persists, you can try
flutter clean
and then try "flutter pub get" again.
Thanks everyone for sharing your views.
Above issue has been fixed by below steps:
Open terminal
Run Below commands
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup
CocoaPods will be available
Quit VC editor and reopen.
do flutter run
Above steps worked for me.
Thanks.

flutter building release mode fails

I am trying to build flutter app in release mode. I tried to do flutter build appbundle in the terminal and i get the following error.
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'sqflite'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/abdu/Downloads/flutter_linux_v1.12.13+hotfix.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0/android/local.properties'.
This is my first time building an app and I don't have no idea how to fix this. Any help would be appreciated. Thank you.
try adding Android home path:
export ANDROID_HOME=$HOME/[folder if you have any]/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file ~/.bashrc (located at home/username/.bashrc) . Run source ~/.bashrc to apply the changes or restart your terminal..
to check
echo $ANDROID_HOME
..

Android studio:import NDK project from eclipse

I exported project from Eclipse(windows) and imported it to android studio V 0.4.2(ubuntu).
The project include working NDK library.
I get this error when try to run my app:
Execution failed for task ':app:compileDebugNdk'.
NDK not configured
From others stackoverflow posts, I understand that it is an issue.
But get no workaround for this.
Should i proceed the development with eclipse for now, or is that the a lazy option ?
EDIT :
I run this command:
export NDK=~/Downloads/android-ndk-r9c
and then :
and then go to my app directory and run this:
ndk-build
And i get this:
yarinkos-u#yarinkosu-MSI-Notebook-EX600:~/AndroidStudioProjects/AndEngineEXperimental$ ndk-build
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 1: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: dirname: not found
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 132: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: uname: not found
ERROR: Unknown host operating system:
What i did wrong?
It seems that the script running,but i miss something there.
EDIT 2:
i mistakenly runing this also :
export PATH=~/Downloads/android-ndk-r9c
so i get the error above.
If i running onlt this :
export NDK=~/Downloads/android-ndk-r9c
I get ndk-build not found error.
NDK Support is introduced from Android Studio 0.4.1 only, so make sure you are running AS 0.4.1 or above.
Android gradle plugin must be 0.7.+ in build.gradle file and also new NDK integration requires NDK r9c .
Lines from Developer tools blog under Release 0.4.1
Supports importing NDK projects. If the imported project contains NDK
sources, these are imported into the jni/ source set of the project,
the module name is inferred from the Makefile and stored in the Gradle
file, and the ndk.dir property is defined in local.properties.
Check more about it here :
http://tools.android.com/recent
you need to download the NDK for your operatings system # https://developer.android.com/tools/sdk/ndk/index.html once it's downloaded, install it it'll extract the contents to the correct file system it needs to be in it'll take some time, also make sure you are running the latest android studio. it worked for me. good luck.