env: sh\r: No such file or directory (React Native) - react-native

Recently I have move from windows to macbook and i want to run my project. What happen with this error "env: sh\r: No such file or directory"? I have been success to create a new project but open my last project have this error. Thank you

This fixes it:
dos2unix android/gradlew

Related

React native link fails with no package found

I'm not sure what exactly is happening but I am unable to run react-native link without errors occuring
CLI Output:
react-native link --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
error No package found. Are you sure this is a React Native project?
error Unexpected close tag
Line: 22
Column: 24
Char: >
debug Error: Unexpected close tag
Line: 22
Column: 24
Char: >
at error (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:666:10)
at strictFail (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:692:7)
at closeTag (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:885:9)
at SAXParser.write (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:1447:13)
at new XmlDocument (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/lib/xmldoc.js:199:15)
at readManifest (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/readManifest.js:44:10)
at Object.projectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/index.js:66:46)
at Object.keys.forEach.platform (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:25:62)
at Array.forEach (<anonymous>)
at getProjectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:22:35)
This randomly started happening after attempting to npm install react-native-firebase.
What I've tried
clear-caches
remove node_modules and npm install
Checking out my code back to a previous commit
Adding my package name to the manifest locaed in /android/app/src/debug/AndroidManifest.xml
Removing the app from my computer and cloning it from github
Running react-native link on another project, which works, but i just can't run react-native link on this specific project.
So the answer to my question was that in my android manifest xml file, there was an incorrect closing brace for one of my intent filters.
So for anyone that this happens to ensure that all of your Android files have correct syntax.
I fixed this problem by closing some unclosed tag in android/app/src/main/androidManifest.xml. Try checking the file line by line.

Error: Cannot find entry file ./node_modules/react-native-scripts/build/bin/crna-entry.js in any of the roots:

I keep receiving this error when running my App.js for React Native that was working perfectly well before I attempted installing Victory charts. Somehow something broke and after over three hours of work I am unable to figure out a solution. I have tried everything I could find on the web including uninstalling watchman, reinstalling watchman, reverting to React Native 0.55.4, some other recommended commands. Nothing is working.I am so confused.
$ yarn add react-native-scripts
This helped.
I think the other library may hurt the installation part of your package. To solve this issue on IOS you need to add its library like below:
First do 'yarn add react-native-scripts'. In the case that it dose't work continue other steps.
1-Go to the node module of your project and find the package folder and find the ios file inside it.
2- Then drag it into ‘library’ section of your xcode. (It is the subset of your project folders)
3- Then go to ‘build phase’ and in the ‘Link binary with libraries’ add it there by clicking on the plus sign
4- Then in some cases you need to add the correct path of the ios file inside your node module in the xcode. To do that you should go to ‘build setting’ section in the xcode and search header there. Then you need to add the path there below other paths.
5- Then clear everything (cmd+shift+k) and then finally compile it.
I hope it works for you.
In my case the "crna-entry.js" file does exist in the roots and my project should work (nothing have been modified from last time when it does work).
After hours searching, finally I figured out the reason:
the packager's directory checking is case-sensitive and in windows terminal the drive "c:/" will not be auto-corrected to "C:/" which will lead to error.
Hope this will help someone who gets the same error.
Below is the full error message:
The development server returned response error code:404 Cannot find
entry file node_modules/react-native-scripts/build/bin/crna-entry.js
in any of the roots:

expo error installing or running app

when I try to run my app on the iOS simulator I get the error :
Error running xcrun simctl openurl booted exp://localhost:19000: An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=60):
The operation couldn’t be completed. Operation timed out
Operation timed out
Error installing or running app. Error: Process exited with non-zero code: 60
any idea how to solve this error ?
This usually is an error with the Simulator. If you remove expo (delete the app) from the simulator and run the command again, it should build fine.
However, if it still fails, Erasing all content and settings on the simulator does the trick too.
FOUNT IT!
you must have a .watchmanconfig file (like below)
File example
When you initialize a project with expo init "projectname", there is no .watchmanconfig file.
So, create one and in this file, just initialize an empty object like this : {}
Then you can start with expo start or yarn/npm start
It solved all my problem.
Hope it does for you too.
For anyone like me also searching this issue, it is possible to un-eject your app and run again like normal. From the docs, Delete the ios and android directories from your project. Delete the isDetached and detach keys from your project's app.json. You can now use your project like a normal Expo project (with no ExpoKit). Read more at https://docs.expo.io/versions/latest/expokit/advanced-expokit-topics/
It may be an issue with some outdated simulators in your simulator cache. On MacOS remove the sub-directories in the following directory:
~/Library/Developer/CoreSimulator/Caches/
check if you have .watchmanconfig file present in root, if not create one .watchmanconfig and initialize empty object and run command npm start again

React Native Android fails: error 3

Hope you could help me here:
I'm currently building an app which I created through CRNA and then ejected. I get the ios version right on but I'm currently struggling a lot with the android version.
When running react-native run-android all I can get is the following error:
Error type 3
Error: Activity class {com.myapp/com.myapp.MainActivity} does not exist.
I've checked app/build.gradle, app/src/main/AndroidManifest.xml, app/src/main/java/com/myapp/MainActivity.java and app/src/main/java/com/myapp/MainActivity.java for name errors on package. I've tried moving from com.myapp to com.mebius.myapp and com aswell.
Seems this comes from the only plugin I'm using. I'm keeping on the investigation
Any hints?
There are 3 possible reasons for the android app build fails to make
1. You need to define sdk path in android/local.properties
if local.properties doesn't place then make a file names with that
add
sdk.dir = home/user/AndroidApp/local/Sdk
You can match with their system path..
2. Your genymotion or avd must enable with the android studio
3. You must have to go with the following command
npm start
in new terminal .
Please go through with it.
Thanks
Actually I had a problem with my gradle config which look like:
include ':react-native-sensors'
project(':react-native-sensors').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensors/android')
rootProject.name = 'accelapp'
I needed to add: include ':app'
I don't know if it's due to the process of ejecting from CRNA or if it's due to react-native link react-native-sensors though.
EDIT After some investigation, I couldn't reproduce this issue. This leads me to say it was a faulty copy/paste...

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'

I am a greenhorn in gradle and i just tried to create a new Android Gradle Project in IntelliJ. After filling up the necessities it started to download something which took hours so i decided to force quit my IDE and open the project again.
And now I am getting this:
And when I open the IDE logs, I see this:
2014-12-13 22:27:37,940 [103759372] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/ramswaroop/Documents/My Workspace/PopoPics'
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:124)
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:112)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:46)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:177)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:63)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:363)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:335)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:214)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:95)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:63)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:552)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:621)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$9.run(ProgressManagerImpl.java:530)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
Caused by: java.nio.channels.OverlappingFileLockException
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:868)
at java.nio.channels.FileChannel.tryLock(FileChannel.java:962)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:51)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:118)
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:112)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
2014-12-13 22:27:37,941 [103759373] WARN - nal.AbstractExternalSystemTask - Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:401)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:309)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:164)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:164)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:369)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:335)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:214)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:95)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:63)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:552)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:621)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$9.run(ProgressManagerImpl.java:530)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
2014-12-13 22:27:37,942 [103759374] WARN - radle.project.ProjectSetUpTask -
2014-12-13 22:27:37,942 [103759374] INFO - radle.project.ProjectSetUpTask - Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
Consult IDE log for more details (Help | Show Log)
INFO: Running on Mac Yosemite with Gradle 2.2 and IntelliJ IDEA 14 Ultimate.
It could be that the gradle-2.1 distribution specified by the wrapper was not downloaded properly. This was the root cause of the same problem in my environment.
Look into this directory:
ls -l ~/.gradle/wrapper/dists/
In there you should find a gradle-2.1 folder.
Delete it like so:
rm -rf ~/.gradle/wrapper/dists/gradle-2.1-bin/
Restart IntelliJ, after that it will restart the download from the beginning and hopefully work.
If you are on Windows, you can go to:
C:\Users\{your_name}\.gradle
And delete all the references of the gradle package you can find in those folders:
caches
daemon
wrapper
Then re-open your project and sync gradle
1 Close Android Studio (AS)
2 Delete the folder in C:\Users.gradle\wrapper\dists\gradle-2.1-all
3 Run as admin
4 Sync your project files
First check your Internet conection..
or try with
Tools -> Android -> Sync
or Try
File -> Settings -> Gradle -> Check Offline Work
I had the same problem.
(My problem is with gradle 4.4 files)
Actually the problem is incorrect downloading of 4.4 gradle which already I had.
When I delete gradle 4.4 version
C:\Users\$Your_User\.gradle\wrapper\dists\gradle-4.4-all
Android studio again downloads gradle-4.4 and syncs with my project.
Now it had rectified with the help of Michelin Man
Thanks for your answer Michelin
I cannot believe the below solution, but it did solve it.
in gradle-wrapper.properties file:
change
distributionUrl=http\://services.gradle.org/distributions/gradle-6.1.1-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
you should also check if you are connecting via proxy. If there is a proxy set it up using File > Settings > Appearance and Behavior > System settings > HTTP Proxy
https://services.gradle.org/distributions/gradle-2.1-all.zip
open this link in the browser and download the zip file and extract it to folder
Before extraction please delete the old folder whose name ends gradle-2.1-all and then you can start extracting
if you are window user extract it to this folder
C:\Users{Your-Name}.gradle\wrapper\dists
after that just restart your android studio.
I hope it works it works for me .
For me, it was just close the android studio and restart as Administrator.
If all above solutions is not working and In case of your project was working fine and now getting this issue, then try this,
go to android studio setting.
select gradle under build,execution.
then again just set path of gradle user home
(C:/Users/%user_name%/.gradle/wrapper/dists/gradle-6.5-bin)
just rebuild again, this helps me.
It could be that the corresponding Gradle version was not downloaded properly.
You could delete the broken file at
rm -rf .gradle/wrapper/dists/
and restart studio.
or try
File -> Settings -> Gradle -> Check Offline Work
and download the file from the official site and extract to the destination location
.gradle/wrapper/dists/
In my case, the problem was that I was not connected to the same VPN with which I installed Android Studio, I do not know why it happens, but even if I have internet access, if I am not connected to the original VPN, the downloads from IDE do not work correctly.
I connected the VPN, I did the gradle again and finally it started to download and install everything correctly.
I also checked that I didn't go through any proxy or anything similar in my Android configuration.
I recently had this same error, but it was due to an outbound firewall / monitoring tool silently killing the download requests in the background.
Sometimes the problem isn't Android Studio or your gradle configuration at all!
In Android Studio, if you open the Design window for the app, there is error message about Gradle being not synched properly. Next to the error, there is a 'Try Again' button. If you click on that, Android studio tries to sycn up again.
That worked for me.
In my case I had to go to
File -> Settings -> Build, Execution, Deployment -> Gradle
and then I changed the Service directory path, which was pointing to a wrong location.
Delete .gradle data
CtrlAltS then navigate to File -> Settings -> Build, Execution, Deployment -> Compiler then check "Sync project with gradle before building, if needed".
My problem was fixed with this method.
Change the distributionUrl=https://services.gradle.org/distributions/gradle-2.1-bin.zip from the Your project folder\gradle\wrapper\gradle-wrapper.properties to new one.
what worked for me is
distributionUrl=https://services.gradle.org/distributions/gradle-6.2.2-all.zip
One more reason for this error (assuming that gradle properly setup) is incompatibility between andorid.gradle tools and gradle itself - check out this answer for the complete compatibility table.
In my case the error was the same as in the question and the stacktrace as following:
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at com.android.build.gradle.BasePlugin.lambda$configureProject$1(BasePlugin.java:436)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
...
I've fixed that by upgrading com.android.tools.build:gradle to the current latest 3.1.4
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
Gradle version is 4.6
I was facing the same problem in IntelliJ. It was working from command line though.
I found the issue was because of an improper Gradle config in the IDE. I wasn't using the "default Gradle wrapper" as recommended:
On MAC Remove gradle-2.1-all folder from the following path /Users/amitsapra/.gradle/wrapper/dists/gradle-2.1-all and then try gradle build again. I faced same issues with 5.4.1-all.
It takes a little time but fixes everything
For me, the reason is that the gradle.zip IDE downloaded is broken (I cannot uncompress it manually), and following steps help.
gradle sync, and it says could not install from ${link}, ${gralde.zip} ...
download from ${link} manually
go to the ${gradle.zip}'s location
replace the ${gradle.zip} with the one downloaded, remove the .lck file on the same path.
gradle sync.
Note:
${link} is something like https://services.gradle.org/distributions/gradle-4.6-all.zip
${gradle.zip} looks like ~/.gradle/wrapper/dists/gradle-${version}-all/${a-serial-string}/gradle-${version}-all.zip
I have also recieved this issue inside of InteliJ.
Go to the gradle/wrapper folder and modify distributionUrl inside of gradle-wrapper.properties to a correct version.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
It also disturb me a lot but now it is fine
The solution is very simple (written blow) [window (android studio)]
go to C:\Users\your user name.gradle
open wrapper/dists and delete the folder that is distrubing you in my case --gradle-6.5--
then go back to .gradle folder and this time open daemon folder and delete the folder with same number that is disturbing you in my case --6.5--
Then again go back to .gradle folder and this time open caches folder and delete the folder with same number that is disturbing you in my case --6.5--
now if your android studio is open then close it and again start it but this time with administrator mode by right clicking on the icon of android studio icon it is important
you should have internet connection and now your android studio will setup every thing by its own (please don't distrub it while it is doing its operation)
I solve it by downloading zip file from https://services.gradle.org/distributions/gradle-2.1-all.zip manually, put it inside C:\Users\<username>\.gradle, and sync.
(Only for Mac Users)
download the gradle file from the link and then close the project then at the front page ,under the creat project option there is option called Import project(Gradle,Eclipse ADT,etc) here you have to select the gradle file which you have downloded earlier .
Then restart the Android studio .....hope your problem is solved now
In my case I solved the problem with
Ctrl + Shift+ F
Type 2.1 or just type the version of the gradle that can't be installed
replace the version of gradle with the correct one in the gradle-Wrapper.properties
File in my case I replaced it with 6.1.1
Guys In my case the gradle is not properly install thats why this issue is happan with me.
Resolution:
Go to User Directory
Then Go to .gradle\wrapper\dists
Remove the folder which you are facing error
Invalidate cache and restart your android studio
Download directly from Gradle: https://services.gradle.org/distributions/
Choose the relative version, pay attention to the name behind the version
Open the folder
as shown
enter image description here
You can delete the contents in the wrapper folder before, replace it with the Gradle file you just downloaded, and unzip it. After unzipping, you can delete the compressed file.
Open Gradle settings. Modify the path problem, and then synchronize it. There should be no problem
Here is what worked for me on windows 10.
Close my project.
Close Android Studio.
Run Android Studio.
Open project.
Android studio takes a few minutes while everything sorts itself out.
I thought that maybe Android Studio just needed sufficient rights to extract and put the files in all the right locations and possibly set the path variables.