How to solve Could not find com.android.tools.build:gradle:4.1.1.? - react-native

Can't build react native app in android studio.
I tried:
Sync Project with Gradle Files, but I can't do it because of an
error
File -> Invalidate Caches/ Restart
Clear cache from $HOME/.gradle
Delete $HOME/.gradle
Change com.android.tools.build:gradle version on 2.3.0, because it's
the latest version in this list
(https://repo.jfrog.org/artifactory/libs-release-bintray/com/android/tools/build/gradle/), but when I use npx react-native init projectName, used Android Plugin Version 4.1.2, but this version there isn't in this list.
Also know the difference between Gradle, Android Gradle Plugin,
Gradle Wrapper, already read https://developer.android.google.cn/studio/releases/gradle-plugin?hl=en. I tryied to use the latest Gradle v. 6.8.2 and Android Gradle Plugin v. 4.1.2, it also didn't help to build the project.
Change distributionUrl in
projectName/android/gradle/wrapper/gradle-wrapper.properties
Change in File->Settings->Build, Execution, Deployment->Gradle use
Gradle from Specified location and set C:/Gradle/gradle-6.8.2, it didn't help and left it at default
I know there are exactly the same questions on stackoverflow and on github, but the solutions haven't helped.
Build output:
Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :react-native-settings
Add google Maven repository and sync project
Open File
Now used:
Gradle v. 6.5
Android Gradle Plugin v. 4.1.2
gradle-wrapper 6.5-all
Android Studios 4.1.2
Android SDK Platform: Android 10, 9, 8.1, 8.0, 7.1.1, 7.0

Your google Maven library is missing. Rebuild project after adding it

Related

aws codebuild runtime verison not supporting latest gradle version 7

I am trying to build my java springboot cod using gradle 7 but getting this error while requires Gradle 6.8.x, 6.9.x, or 7.x. The current version is Gradle 5.6. How can i get the latest version of gradle
Hard to tell without much details on the build failure. I had issues myself trying to build in CodeBuild with gradle 7 and I solved by:
Make sure the source code pulled by CodeBuild contains the gradle/wrapper folder and all its contents (including the jar file).
Check in the gradle-wrapper.properties have the distributionUrl to the gradle distribution for your project.
Use ./gradlew build as a command in CodeBuild.

Robolectric 4 AndroidX NoClassDefFoundError MonitoringInstrumentation with IntelliJ 2018.3.4

Problem
after switching to androidX
with a multi-module Android library
using IntelliJ 2018.3.4 #IC-183.5429.30
using Robolectric 4.1 with android gradle plugin 3.3.1
when executing Robolectric tests, I receive:
java.lang.NoClassDefFoundError: androidx/test/runner/MonitoringInstrumentation
No duplicate question:
I read the other topics which pop up when using google or stackoverflow search but they are about a more specific error which is worked-around via adding specific dependencies. In my case I was not able to determine which dependency to add.
I add dependencies to androidx.test:core
for the build type under test.
In my case it was debug so in the build.gradle I add
debugImplementation 'androidx.test:core:1.2.0'
I read that no workaround should be required with Android Studio 3.3 and Robolectric 4.0.
Use Android Studio 3.3.1+ with Robolectric 4.0+
This works for me.

After Flutter GIT project checkout, unable to run the project

So I created a Flutter project in IntelliJ Idea Community Edition on machine A and then uploaded the whole project on GitHub. Now I cloned/checked out from GitHub in the same IDE on machine B, performed the following:
flutter packages get
flutter upgrade
Set up the dart path and all other prerequisites
But, I am still unable to run the flutter project from IDE.
I mean I can't even press the "Run" button.
Where did I go wrong?
You can try performing the same steps as I did. it if you want. Here's the Git repository code
Edit I can run the same project via terminal.
[Update] As requested by Günter Zöchbauer in the comment log, here's the logs for flutter doctor -v
BoringFlutterProject$ flutter doctor -v
[✓] Flutter (Channel dev, v0.5.8, on Linux, locale en_IN)
• Flutter version 0.5.8 at /home/daksh/flutter
• Framework revision e4b989bf3d (8 days ago), 2018-08-09 09:45:44 -0700
• Engine revision 3777931801
• Dart version 2.0.0-dev.69.5.flutter-eab492385c
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /home/daksh/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = /home/daksh/Android/Sdk
• Java binary at: /home/daksh/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.1)
• Android Studio at /home/daksh/android-studio
• Flutter plugin version 25.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] IntelliJ IDEA Community Edition (version 2018.1)
• IntelliJ at /home/daksh/Downloads/idea-IC-181.5281.24
• Flutter plugin version 25.0.2
• Dart plugin version 181.4892.1
[✓] VS Code (version 1.26.0)
• VS Code at /usr/share/code
• Flutter extension version 2.17.1
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
I posted this question because I'm sure many of us will face the same problem, just like we used to face some issues in AndroidStudio back then
It is an Android Studio issue. The IDE doesn't apply the flutter SDK location for every new project you clone.
The workaround is to open the cloned project go to File>Settings(Ctrl+Alt+S). In 'Languages & Frameworks'>Flutter set the SDK path to your Flutter SDK location (e.g. C:\src\flutter). Once you apply the changes and run the 'Packages Get' command the cloned project is fully accessible and understood by Android Studio.
I've succeeded to run you project. When I've first open it showed me that it can't find the location for Dart SDK, once I've set the location of the flutter sdk
as explained here:
Dart SDK is not configured
it automatically update the location of the Dart SDK, then I've had to run get dependencies, then it run.
If you have flutter and Dart plugin installed.
Now the problem is Dart support for this project is disabled now you have to enable it.
Step 1: Go to Settings -> Languages & Frameworks -> Dart
Step 2: Check the "Enable dart support for this project"
Step 3: Set the Dart SDK path to your Dart SDK folder like the picture given bellow
Step 4: Click on Apply
That's all!
Too late but pubspec.yaml-> Pub outdated( on top left of Android Studio's screen) -> build on real device solved my problem
In addition to answer by #Marc Steffens above, to run on Chrome and not an emulator or device, I also had to run "flutter create ." from the project root in the terminal. Note the trailing ".".
What helped in my case, was simply removing the .idea folder in the project root.

How can I upgrade react-native gradle version

I need help.
I can't upgrade gradle version of my react-native project.
I try a lot of things, downloaded last version of Android Studio & SDK Tools etc.
I changed this file \android\gradle\wrapper\gradle-wrapper.properties, I tried to upgrade using npm install -g react-native-git-upgrade but still I can't upgrade it.
When I react-native eject It's exports
"distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip"
Waiting for answers.
In android/build.gradle you have to edit this line
classpath 'com.android.tools.build:gradle:x.y.z'
Change x.y.z with the version you want. Edit it with Android Studio then click Sync now
In {yourProject}\android\gradle\wrapper\gradle-wrapper.properties, update:
distributionUrl=https\://services.gradle.org/distributions/gradle-{your version}.zip
Find your version of gradle with
gradle --version
You may need to install gradle wrapper if you haven't already.
you can go to https://services.gradle.org/distributions/ and check that latest -all.zip version of gradle and update the same in your gradle-wrapper.properties file. When you run your react-native app the next time, your gradle will first get upgraded and then run.
There are two things
Android Gradle Plugin
You can see the version of it in android/build.gradle file and update it using Daniel's answer here
Gradle version
You can see this in android\gradle\wrapper\gradle-wrapper.properties file and update it using the answer mentioned here
To know the difference between them refer following links:
https://developer.android.com/studio/releases/gradle-plugin
difference between android gradle plugin and gradle
Open Android Studio and navigate to File → Project Structure
Then click on the Project option.
then choose the latest version of Gradle. After that click on Ok.
From Gradle's site:
https://gradle.org/install/#with-the-gradle-wrapper
Upgrade with the Gradle Wrapper If your existing Gradle-based build
uses the Gradle Wrapper, you can easily upgrade by running the wrapper
task, specifying the desired Gradle version:
$ ./gradlew wrapper --gradle-version=6.6.1 --distribution-type=bin
Note that it is not necessary for Gradle to be installed to use the
Gradle wrapper. The next invocation of gradlew or gradlew.bat will
download and cache the specified version of Gradle.
$ ./gradlew tasks
Downloading https://services.gradle.org/distributions/gradle-6.6.1-bin.zip ...
Run these commands in your project's android folder
I had opened my project in Terminal and ran open -a /Applications/Android\ Studio.app to open Android Studio but so that it can access node to download my gradle version which it did automatically.
Learned from this original post: React Native on Android: Cannot run program "node": error=2, No such file or directory
For react native
Go to File -> Project Structure -> Change gradle version to 6.1.1 plugin version to 4.0.0
Try different combinations
Use this link - https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle

use gradle to compile any android project in first time,gradle.zip always download again?

ext:
OS: window8 x64
android studio 2.1.3
gradle plugin 2.1.3
gradle 2.14.1
I have already download gradle-2.14.1.zip when compile project last time, use git clone project from github, modify graldw-plugin version and distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip in graldle-wrapper.properties
In embed Terminal run gradlew build it download gradle again,like this(sorry pic not allow enbed) (redundant file take up more C disk rest space) how to solve?