I have a react-native project in which I want to use firebase notification. I found react-native-firebase as a most popular library to do that. The problem is after installing the last version of react-native-firebase, the project cannot be build because of the mismatch between my project gradle version (It's a guess) and react-native-firebase. Also I cannot add other configurations to build.gradle file.
Error:
* Where:
Build file '/home/hassan/Documents/project/ems/reactApp/node_modules/react-native-firebase/android/build.gradle' line: 3
* What went wrong:
A problem occurred evaluating project ':react-native-firebase'.
> Could not find method google() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
As I'm not so expert with android studio and gradle, I cannot come up with an idea to figure it out. To put in the nutshell my questions are:
I installed the last version of the android studio and react native. why the build.gradle file looks old (e.g I can see compile instead of implementation).
How can I upgrade my react-native project to use last configurations of gradle?
Should I use an environment variable to specify the last version of gradle?
Update distributionUrl in gradle-wrapper.properties (android/gradle/wrapper/gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Also, make sure to follow the installation steps in the following link https://rnfirebase.io/docs/v4.3.x/installation/android
Related
In Mac, I've setup Flutter in Android studio. When I'm running project it gives me error
* What went wrong:
Execution failed for task ':location:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
I'm using all latest versions of Flutter, Kotlin, Gradle etc.
You need to equalize kotlin version in first row which is ext.kotlin_version = '1.6.10' to according to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" of underlined $kotlin_version
After this, the problem will solve...
Actually I found a solution for my problem. There are 2 dependency defined in .yaml file 1. geo_location and 2. location.
After removing the location dependency from .yaml file and run command flutter pub get I can successfully build android build from Mac. This solution might not be global but solution of my problem I found this.
Thank you!
Happy coding.
I try to clone my teammate project, i did yarn install and run android but when the process is done, i found an error said:
A problem occurred evaluating project ':#mauron85_react-native-background-geolocation-common'
Other explanation are:
Failed to apply plugin [id 'com.android.internal.library']
The option 'android.enableUnitTestBinaryResources' is deprecated.
The current default is 'false'.
It has been removed from the current version of the Android Gradle plugin.
The raw resource for unit test functionality is removed.
We still want to use this dependecy because it requires on our project, my React Native version is 0.61.5
is there any solution regarding this problem?
Add the following line in gradle.properties in android folder.
android.enableUnitTestBinaryResources=false
Long story short: My android phone keeps disconnecting from ADB. I was told to update android studio, did that. I open my project in Intellij and try to run on android and I get an error:
BUILD FAILED
Total time: 48.986 secs
Error: /Users/me/Desktop/comp/Development/comp-ionic/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> java.lang.NullPointerException (no error message)
My first thought is that my gradle is the wrong version. For this specific app, I need to use gradle version 2.14.1.
When I type gradle -v I'm getting version 3.3.
Is there a way to delete/downgrade gradle from 3.3 to 2.14.1?
Or is this another problem?
If you're using the gradle wrapper, then there'll be a folder in your project named "gradle" with a subfolder named "wrapper", inside that, there are 2 files:
- gradle-wrapper.jar
- gradle-wrapper.properties
Open "gradle-wrapper.properties" and change the place where it says "3.3" to "2.14.1". Then sync gradle, and it will automatically download 2.14.1.
If you're using the new 2.3 Android Studio, you HAVE to use gradle wrapper 3.3, as its the minimum supported gradle wrapper version. If so, then you'll have to download Android Studio 2.2, or fix whatever issue you have in your project that needs gradle wrapper version 2.14.1.
To get more information about whatever the issue is, try running this:
./gradlew clean assemble -stacktrace
That will clean your project, try and compile it, and if/when it fails, it will show you a stacktrace of the error.
What you should do is to change the gradle build tools version to the one that matches your gradle version. According to here you can set the gradle to 2.14.1 by changing build tools to lower than 1.0.0.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'// For gradle 2.2.1 - 2.3
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Notice: if you keep checking the mentioned link you'll see Higher is better for gradle.
For me, Android Studio > File > Invalidate Caches / Restart did the trick.
I got the same problem when upgrading to Android Studio 2.3.1. There is something funky about Gradle 3.3 (It fails by "java.lang.NullPointerException: null value in entry: destinationDir=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)").
Good news: seems like the current most recent version (3.5) works.
Go to File|Project Structure|Project, and use these versions:
Gradle version=3.5
Android Plugin version=2.3.1
I update the Android Studio version to 3.3 Canary 4, then update the gradle plugin, and the project stops working.
I do not know how to restore my AS to the previous state, nighter the gradle plugin.
But just with this command, the project now works, for me: gradlew clean assemble -stacktrace, in terminal tab in AS.
I want reading an open source project so I select k9mail for start. The recommendation was run and reading this code in Android Studio. I import k9mail project to AS 1.2.1.1 version. I download gradle 2.4 version and added this in environment variable. When I want to run this application, but I receive some errors that I describe below:
1) When I click Run (Alt+Shift+F10), select Android Application, select my module (there is k9mail) and select USB Device, then I see a warning:
No JDK specified for module 'k-9-master'.
2) When I click on Run (Shift+F10), I faced this error in messages tab:
Gradle DSL method not found: 'android()'
Possible causes:
A)The project 'k-9-master' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file
B)The build file may be missing a Gradle plugin. Apply Gradle plugin
When I updated gradle to 2.4, I changed classpath 'com.android.tools.build:gradle:1.2.3' to 'classpath 'com.android.tools.build:gradle:2.4'' from build.gradle of k9mail, but my problems were not solved.
I googled but I can't find solutions for my problems.
No jdk specified for the module.
For that you have to specify the jdk path through Project Structure.
You may also verify by looking at local.properties
For gradle related issues you just kindly update your gradle build and SDKs to latest versions.
This will minimize your gradle issues.
In Android Studio, I simply created a new project, and it says that:
Gradle project sync failed. Basic functionality will not work properly.
I have searched the web and tried everything, but nothing worked. I have v0.4.6 of Android Studio using Gradle 1.11.
The Error Message Is:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Vinnie\AndroidStudioProjects\MyFirstAppProject\MyFirstApp\build.gradle' line: 9
* What went wrong:
A problem occurred evaluating project ':MyFirstApp'.
> Gradle version 1.10 is required. Current version is 1.11. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Vinnie\AndroidStudioProjects\MyFirstAppProject\MyFirstApp\gradle\wrapper\gradle-wrapper.properties to gradle-1.10-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 7.011 secs
The Android plugin 0.8.x doesn't support Gradle 1.11, you need to use 1.10.
You can read the proper error message in the "Gradle Console" tab.
EDIT
You need to change gradle/wrapper/gradle-wrapper.properties file in this way:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
In my case NDK location was the issue.
go to File->Project Structure->SDK Location and add NDK location
This may be helpful for some.
My problem exactly is incomplete gradle-1.12-all file download.
Below is screen shot of the Error
I re-downloaded the file from the gradle site here and extracted it in path/to/the/gradle, in my case was in C:\Users\maneeOsman\.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo
I closed the android studio and reopen it in administrator privilege (Run as administrator).
The android studio starts downloading the necessary files for building and debugging. You can notice that from bottom-left indicator bar.
After this, it is working fine.
See the screen shot below
Here is the solution I found: On the project tree "app", right click mouse button to get the context menu. Select "open module setting", on the tree "app" - "properties" tab, select the existing "build tools version" you have. The gradle will start to build.
I have encountered this problem And I solved it as follows: File->Sync Project with Gradle Files
good luck!
After applying this fix that was found here... https://code.google.com/p/android/issues/detail?id=208295
in file $SDK/ndk_bundle/source.properties replace "12.0.2753695 beta 1" to "12.0.2753695-beta1"
My project was built successfully and ran on device and emulators although 5 warnings still remains.
Remove the dependency "junit:junit:4.12" from app modules...!!! This solution is for gradle to sync all files.
it was hard to solve but i did it
look go to
C:\Users\Vinnie\
delete .gradle file
its you didn't see it it may be in hidden files so if you use windows 7
right click then click on properties and click on hidden to be not checked
then the file will appear then delete it
i hope this works
I know this is an old thread but I ended up here with the same issue.
I solved it by comparing the dependencies classpath in the build.gradle script(Project) to the installed version.
The error message was pointing to the following folder
C:\Program Files\Android\android-studio3 preview\gradle\m2repository\com\android\tools\build\gradle
It turned out that the alpha2 version was installed but the classpath was still pointing to alpaha1. A simple change to the classpath ('com.android.tools.build:gradle:3.0.0-alpha2') was all that was needed.
This may not help everyone, but I do hope it help most people out.
I was behind firewall|proxy.
In my case with Studio, ERROR: Gradle sync failed & Cannot find symbol.
I have used
repositories {
jcenter(); // Points to HTTPS://jcenter.bintray.com
}
Replace it with http and maven
repositories {
maven { url "http://jcenter.bintray.com" }
}
i had same issue i solved by changing gradle plugin version and and gradle version
see image for more refrence
Use this line to your Build gradle app
repositories {
maven { url "http://jcenter.bintray.com" }}
Using an outdated gradle version may also result to fail in synchronization.
Download latest version from https://gradle.org/releases/ and download the "complete" latest version.
Now replace it with the outdated version which is located C:\Program Files\Android\Android Studio\gradle.
Go to settings(ctrl+alt+s) ,go to gradle and add the the new gradle directory in "use local gradle distribution" "Gradle home:C:\Program Files\Android\Android Studio\gradle\gradle4.4.1 ."
It Worked for me.
Hope u understand.
Update for 2018:
I have faced this issue recently and it was resolved by updating android studio & updating gradle when prompted then rebuilding the project
I had a "Install build tools and sync" link in the lower right hand corner of my screen. I clicked on that and it fixed the issue.
Each version of the Android Gradle Plugin now has a default version of the build tools. For the best performance, you should use the latest possible version of both Gradle and the plugin.
You recive this warning in case if you use latest gradle plugin but not use latest SDK version. For example for Gradle plugin 3.2.0 (September 2018) you requires Gradle 4.6 or higher and SDK Build Tools 28.0.3 or higher.
Although you typically don't need to specify the build tools version, when using Android Gradle plugin 3.2.0 with renderscriptSupportModeEnabled set to true, you need to include the following in each module's build.gradle file: android.buildToolsVersion "28.0.3"
see more https://developer.android.com/studio/releases/gradle-plugin
Update gradle to the latest available version and implement libraries to the latest version available, also check if google play services is latest if used.