I followed the official firebase android guide, but whenever I try to instantiate the FirebaseFirestore, I get a "cannot resolve symbol" error. The issue is as shown below:
Before this is marked as a duplicate, I have been searching for a solution to this issue for hours now. Nothing I found online works. Below is my gradle config:
app:
root:
Is there any idea what I am doing wrong? I have tried various different plugin versions for fireStore and firebase app but nothing seems to work
it all hints for, that the artifact had not yet been downloaded...
check if Gradle isn't in offline mode; and sync or build the project once.
alternatively, run ./gradlew clean assembleDebug from a terminal.
repository mavenCentral() is also rather relevant than mavenLocal().
while the repository for these artifacts should be the google() one.
another known issue is, that one may have to prefer IPv4, in the gradle.properties file:
org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
Try adding this to your gradle
The FirestoreRecyclerAdapter class is part of the FirebaseUI Library but not the core Firestore SDK
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
Try close your project and reimport it again
Looks like you have missed import statement
import com.google.firebase.firestore.FirebaseFirestore;
Try this:-
In Android Studio, click on File.
Then click Sync Project with Gradle Files.
I Recently Had that Error and this are the steps that I tried, I am not pretty sure which one of these did the trick but the error was solved and I was able to utilize fireStore. These are not in any Order I just randomly continued doing these.
I hope these helps.
Check for these
1. Have You Installed Google Play Services and Google Repository.
Check for the Updated Version and install it if available.
2. Try to Match All the Versions in the gradle config: app ... for eg,
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-firestore:16.0.3'
Sync Those Files for Quite few times
3. Clear Caches and Restart the Android Studio IDE
Step 1:- Go to File Menu > Invalidate Caches/Restart..
Step 2:-
Click on Invalidate and Restart on the Window that Appears
This
will restart the project and rebuild it, Stay calm as this can take
quite a time.
After Following These Steps all my Error were Solved and I was able to instantiate the FirebaseFirestore.
project build.gradle
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}}
I recently faced this problem. There is a simple solution.
Add this to your app Gradle:
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
Import the following statement:
import com.google.firebase.firestore.FirebaseFirestore;
Thank me later :)
Related
I've spent hours trying to import/use a custom github repo for an android app and am having no luck. I'm new to Android Studio but can't seem to import the repo such that I can use its methods. I've tried a lot of recommendations from here and the wider web without success. Probably because the posts I have come across are 5+ years old...
Have tried adding the following to to build.gradle (:app), but I get an error "Failed to resolve: com.github.pkleczko:CustomGauge:1.0.4":
implementation 'com.github.pkleczko:CustomGauge:1.0.4'
Have tried adding the the following to the above, but this gives me the error "Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle'":
repositories {
mavenCentral()
}
Have tried using New -> Import Module and New -> Project from Version Control per this, but these just opened the repo in a new window.
Having CustomGuage as a dependency for my app module didn't seem to do anything either.
It shouldn't be this hard, should it?! Please help, what am I doing wrong?! Do I need to import the project and then refactor it for my needs rather than using it as a 'library'? Do I need to add an import statement to my java file?
Thank you!
This is an old project. You can see his warehouse introduction. He uploaded it in jcenter. Of course, mavenCentral will not.
this is repository -> pkleczko/CustomGauge
I need help with the following problem:
Right now, I want to use my Java Gradle Project to build this github-project:
https://github.com/PaperMC/Paper but the project but it's a maven project.
I found a plugin for adding github projects as dependencies but it fails here.
An alternative would be to use this jenkins here: https://ci.destroystokyo.com/job/Paper/
However here I'm struggling to make my gradle always use the newest build without having to reasign the chaning version numbers by hand.
Can someone help me out because I have no idea what and how to add to the build.gradle.
Thanks in advance!
Edit:
I found the Maven-Syntax for the correct pull here:
https://paper.readthedocs.io/en/paper-1.11/developers/#plugin-developers
But when I try to convert the information to Gradle I still fail when I try to leave out the version so that Gradle would fetch the latest one. Can someone provide a valid snipped for this? I have never done this before.
According to this guy, you can use a fake ivy repository.
As https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar points on the latest build, just set up your repository like this :
repositories {
ivy {
url "https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/"
layout 'pattern' , {
ivy '[module]-ivy.xml'
artifact '[module](.[ext])'
}
}
}
And then, use the dependency (the group is not relevant here)
dependencies {
compile 'anything:paperclip'
}
It will get the right file
$ gradle build
Download https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar
...
I cloned the project from here git clone https://github.com/googlevr/gvr-android-sdk.git
I imported the gvr-android-sdk project into Android Studio:
Opening the buid.gradle for the samples-sdk-treasurehunt project I see the following dependencies:
dependencies {
compile 'com.google.vr:sdk-audio:1.60.1'
compile 'com.google.vr:sdk-base:1.60.1'
}
See image here:
What am I missing?
If you take a look at https://bintray.com/google/googlevr/sdk-audio
It shows that version 1.60.1 hasn't been pushed to the repository yet. Try setting the versions to 1.60.0 (the latest pushed version)
edit: you may have imported the wrong folder, you need to import the folder that you cloned the repository to (as you need to project-level build.gradle), instead of import gvr-treasurehunt import gvr-android-sdk
Subscribe to the recently create issue at https://github.com/googlevr/gvr-android-sdk/issues/431 where I've added an initial solution (change ALL dependency references to 1.60.1 to 1.60.0, not just for the sample you're building.
I'm new in Gradle. I'm trying to add gdx-tools to my project:
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
I open my Desktop project, folder "Gradle Dependecies" and see "gdx-tools-1.0.1.jar". As I try to open it - nothing shows.
So, when I try to use it ( I want to try pack images to atlas) - I can't import com.badlogic.gdx.tools...
What I do wrong?
I had the same problem. So I put "com.badlogicgames.gdx:gdx-tools:1.9.2" into my browser to see where it took me. (1.9.2 being my gdxVersion) Sure enough it did not take me to a page but to a search result. I followed the first one:
http://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-tools/1.5.2
Which says there is a new version - 1.9.2 (well, duh - that's what I'm trying to reach. Thankfully, there's a link and I follow it.)
http://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-tools/1.9.2
Now, in the upper center of the page you'll see a tabbed box with code in the middle. Select Gradle and copy that code.
Back in your Gradle file add:
compile (paste)
Or, in my particular case:
compile 'com.badlogicgames.gdx:gdx-tools:1.9.2'
Now hit sync. This worked but I was worried about hard coding the gdxVersion number so I played around. If you replace the 1.9.2 with $gdxVersion and the single quotes (') with double quotes (") it should sync. So now my Gradle line looks like this:
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
Why? This seems identical to the version I tried first. I don't know. But these are the steps that led to a successful sync for me.
On this site they give you a detailed explanation on how to update your dependencies.
https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle#tools-gradle
After you put in what they say in the gradle, right click on your project and do gradle -> refresh dependencies.
I don't know if it really helps, but hopefully it can help someone!
If you use modern IDEA or Android Studio, then any time you need new dependency to be downloaded, just add
compile "group:artifact:version"
inside dependencies {} section (like you've done), click
and wait for gradle build/indexing to finish.
Also, in your case, check that $gdxVersion is correct. You must have something like:
buildscript {
ext {
gdxVersion = '1.6.0'
}
}
You can also create a task in your project just to print it:
task someName << {
println $gdxVersion
}
then call it from command line:
./gradlew -q someName
Also you can check out that repo - it has optimized gradle files, so it builds somewhat faster. At least it was so, I don't watch what the libgdx guys were doing for some time
I got the same problem. My solution is - go Project/Structure, search gdx library by name "gdx", add this library to your project, and then you'll be able to add gdx-tools to your build.gradle.
Did you use the gdx-setup.jar file to create your project ? You can find it in the wiki, it is the official way to create a new project
I am building an application using Gradle, JDK 8, Java FX, and Test FX. I need to be on JDK 8 for our application to work on all platforms with our tech stack. My problem is that I am unable to get code coverage into our build. I found this link...
https://github.com/jacoco/jacoco/issues/74
...and using the Jacoco preview build at the top, I was able to replace my intellij JARs and successfully run my tests and get the coverage. However, I am having trouble putting this into my build.gradle. From what I can tell, I need to add a local repository in my build script...
...
apply plugin: "jacoco"
...
buildscript {
repositories {
// Local Repo
// MVN Repo(s)
}
dependencies {
// Classpaths
}
}
jacoco {
toolVersion = "0.6.4.201311160552" // I need this specific version, which isn't on a MVN repo
}
...I tried to add my local repo several ways including...
flatDir(dirs: "lib")
flatDir dirs: "${projectDir}/lib"
maven { url uri("lib") }
one or two other ways I forget
...my lib folder contains the exact contents, unchanged, from the preview build zip's lib folder in the link above. It doesn't seem like gradle is having a problem locating the local repo, but it is having trouble finding the JAR. I assume there is something wrong with the way I am naming it or the way that it is "packaged". I have tried modifying the JAR names but I keep getting the error...
What went wrong:
A problem occurred configuring root project 'myProject'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find :org.jacoco.agent:.
Required by:
:myProject:unspecified
...any ideas why my JAR is not being found? Thanks!
"Answering" my own question, despite the fact that I still haven't quite figured it out. Anyways, here are two links I found that seem to solve my problem...
http://forums.gradle.org/gradle/topics/jacocotestreport_is_skipping
...following some of these instructions allow my tests to run, but I am still not able to run "gradle jacocoTestReport" without it failing.
UPDATE
OKAY! I figured it out, the link above did help me figure it out. My problem was with the asm-all JAR, since there were several, I did not know which one to use. In order to get jacoco working with Java 1.8, you do not need to specify the toolVersion property. All you need to do is add the following to your dependencies block (not the buildscript block, the code block)...
jacocoAgent files(
"$projectDir/lib/org.jacoco.agent-0.6.4.201311160552.jar")
jacocoAnt files(
"$projectDir/lib/org.jacoco.ant-0.6.4.201311160552.jar",
"$projectDir/lib/org.jacoco.core-0.6.4.201311160552.jar",
"$projectDir/lib/org.jacoco.report-0.6.4.201311160552.jar",
"$projectDir/lib/asm-all-5.0_BETA.jar")
...where the asm-all-5.0_BETA.jar is taken from the org.ow2.asm group found at...
http://mvnrepository.com/artifact/org.ow2.asm/asm-all/5.0_BETA
...hope this helps!
for reference, latest jacoco libs are changed so i'm sharing the following snippet:
dependencies{
jacocoAgent files("$rootProject.projectDir/lib/org.jacoco.agent-0.8.3.201904130250.jar")
jacocoAnt files("$rootProject.projectDir/lib/org.jacoco.ant-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/org.jacoco.core-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/org.jacoco.report-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/asm-7.0.jar",
"$rootProject.projectDir/lib/asm-tree-7.0.jar",
"$rootProject.projectDir/lib/asm-commons-7.0.jar"
)
}