I am using Android Studio and (tried) to add firebase.analytics via the menu (tools->firebase). I added the analytics function but
import com.google.firebase.analytics.FirebaseAnalytics;
results in an error since "analytics" cannot be resolved.
What is missing?
Many thanks!
Please make sure you've compiled all needed firebase libraries for analytics in your gradle app file.
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
Check this for more information : https://firebase.google.com/docs/analytics/android/start/
Related
I have been dealing with a problem in android studio gradle for hours, and i could not solve it.
I am just trying to build my very first projects but there is a problem with gradle.
This is how my build.gradle file looks like:
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
}
enter image description here
This is the context of problem:
A problem occurred configuring root project 'My Application'.
> Could not resolve all files for configuration ':classpath'.
> Could not find gradle-7.4.0.jar (com.android.tools.build:gradle:7.4.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.4.0/gradle-7.4.0.jar
> Could not find builder-7.4.0.jar (com.android.tools.build:builder:7.4.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/7.4.0/builder-7.4.0.jar
> Could not find bundletool-1.11.4.jar (com.android.tools.build:bundletool:1.11.4).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.11.4/bundletool-1.11.4.jar
> Could not find protos-30.4.0.jar (com.android.tools.analytics-library:protos:30.4.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/30.4.0/protos-30.4.0.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I also added the image.
I don't know how to fix this, and any help would be appreciated.
I've observed the same issue. I've found some ambiguities that might explain what's going on.
If you naviagate to https://maven.google.com/web/index.html#com.android.tools.build:gradle:7.4.0 you'll get a web page that will give you information about com.android.tools.build.gradle-7.4.0. If you hover over the link for the jar or pom file you'll get a different url from the ones that your search indicated: https://dl.google.com/android/maven2/com/android/tools/build/gradle/7.4.0/gradle-7.4.0.jar. Notice that the "/dl/" part is missing. That's at least what my browser was showing me at the bottom of the browser window. Seeing that, I went into my setting.gradle.kts file and edited my pluginManagment repositories section by added the following repository:
maven {
url = uri("https://dl.google.com/android/maven2/")
}
I was then able to build my project without getting an error about not finding the com.android.tools.build.gradle plugin. In my case, I saw a slightly different list of locations of what it was searching for. Mine was failing because it couldn't fine the gradle-7.4.0.pom file, and not the jar file. So, I'm not exactly seeing exactly what you're seeing, but there's a good chance it related since the pom file is normally read before the jar file when resolving plugin artifacts from a repository.
When I was getting the problem, I would copy the link of the repositories searched and paste it into a browser and sure enough I would get an http 404 error using those searched url location. And when I modified the link by removing the "/dl/" part of the link, the file would download. So, you might think that my explanation explains the issue. However, after I got the issue resolved, I reentered the URL that was failing in my browser (the url with the "/dl/" part), but this time it worked correctly without any errors. The only explanation that I can come up with on why the url sometimes works and sometimes fails is that the server or proxy server processing that url request is sometimes offline.
With all of that said, you may run into the next issue. In order to use android gradle 7.4 you must be using an version of android studio greater than Android Studio Dolphin | 2021.3.1 Patch 1. see https://developer.android.com/studio/releases#android_gradle_plugin_and_android_studio_compatibility Unfortunately, it is my understanding that all of the versions of Android Studio, that would be compatible with using android gradle plugin 7.4 are only available as preview Android Studio releases. So if you're developing and restricting yourself to only building code using officially released stable tools, you're stuck using android gradle plugin 7.3.1, until the next version of android studio gets official released.
There is plenty of "chatter", but I did not find an answer for my project.
While performing the Gradle Sync in my project with Crashlytics, Gradle fails to sync. I have other projects that are just fine and when I 'diff' the build.gradle files and other Android Studio settings, they have the same values and settings related to Crashlytics.
A problem occurred configuring project ':app'.
> org.gradle.api.GradleException: Crashlytics could not determine stripped/unstripped native library directories for project ':app', variant Debug. These are required for generating symbol files when NDK build tasks cannot be automatically inferred. Please specify strippedNativeLibsDir and unstrippedNativeLibsDir in the firebaseCrashlytics extension.
I am not looking for someone to triage my configuration, instead I want to know where in my project files can I find the "firebaseCrashlytics extension" and its configuration and where are the stripped and unstripped files so I can supply a path? If you know the answer from documentation, please share the link.
Make sure your android/app/build.gradle has the following:
release {
// ...
firebaseCrashlytics {
nativeSymbolUploadEnabled true
strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
}
// ...
}
See https://github.com/invertase/react-native-firebase/issues/4253#issuecomment-797187492
In my case, I had a few projects cloned locally of the same repo. One of them was for a too old branch. Like 3-4 years back. For it, I have given a path to another NDK in the local.properties file.
ndk.dir=C\:\\NDK\\android-ndk-r13b\\android-ndk-r13b
It was causing my problem with the recent branches. After deleting it - it worked. So even if it is not the exact same case for you - it is most likely that you are building with the wrong SDК. Try updating in the SDK manager or maybe actually try explicitly saying what you need as I was doing above.
In my project-level build.gradle, Android Studio recommends updating the the firebase-crashlytics-gradle from 2.1.1 to 2.4.1. When I take the upgrade recommendation, the gradle sync fails, therefore I am unable to build my project. The error was obscured as I inherited this old project that is several versions behind and I updated all (most) of the frameworks and could not pin-point to this single dependency. I started over and upgraded selectively piecemeal until this was the lone down-level dependency.
I will try again at a later time when there is yet another update
to include.
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'org.jacoco:org.jacoco.core:0.8.0'
// Unable to build with v2.4.1 of firebase-crashlytics-gradle on this version of build (2021/02/02)
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
}
I am trying to use the runnerup project but I get the below error. My Android Studio is 2.1.3:
I am adding one more thing, I have faced same problem and fixed by downloading below source code via below github link and placed on ANT-Android-SDKs folder (if folder is empty).
https://github.com/ant-wireless/ANT-Android-SDKs/tree/c35bcf8ee9b6379e405693dbd6bec506ec533669
I believe you do not have the correct ant+ library
For the runner up project you need to make sure that you have the code pointing towards the correct .jar file. In this case I do not think it is picking up the ../ANT-Android-SDKs/ANT+_Android_SDK/API/antpluginlib_3-1-0.jar in your hrdevice build.gradle.
dependencies {
provided files('libs/samsung_ble_sdk_200.jar')
compile files('../ANT-Android-SDKs/ANT+_Android_SDK/API/antpluginlib_3-1-0.jar')
I want to implement GCM Client on Android.
Following the guide here
https://developers.google.com/cloud-messaging/android/client
I have downloaded the configuration file and copied the google-services.json file into the app/ directory of the project.
I have also added the dependencies in the project's build.gradle
classpath 'com.google.gms:google-services:1.3.0-beta1'
and plugin in the app level build.gradle
apply plugin: 'com.google.gms.google-services'
I have also included the Google Play Services SDK
compile 'com.google.android.gms:play-services:6.+'
I have also updated the AndroidManifest.xml file as shown here
https://developers.google.com/cloud-messaging/android/client
To get the Registration Token, when I use the following code
InstanceID instanceID = InstanceID.getInstance(this);
Android Studio does not recognize the class. I get a "Cannot resolve symbol 'InstaceID'". Any reason as to why this is happening?
Update your Play services SDK to
compile 'com.google.android.gms:play-services:7.5.0'
Then clean your Project.
Worked for me. Hope it works for you too!
you are missing the gcm
add on your gradle:
compile "com.google.android.gms:play-services-gcm:10.2.6"
Basically, you have to use the latest version of the Google Play Services, Android Support Repository and Google Repository for this to work, and then include the latest version of the Google Play Services
compile 'com.google.android.gms:play-services:7.5.0'
Checks an official firebase documentation and imports the latest version om.google.firebase:firebase-messaging
eg: implementation 'com.google.firebase:firebase-messaging:17.3.3'
I am using IDEA - 11.1.1 and gradle - gradle-1.0-milestone-9 (I tried with release candidate 3 also) on windows-7 (if this matters)
After importing gradle porject, IDEA complains about String object. I think I am missing something about grrovy configuration. I have also marked - main and test folder as Sources and Test Resources respectively. Did I miss something obvious?
Most likely the JDK isn't set correctly in IDEA. Go to File -> Project Structure -> Project and check/fix Project SDK.
Try checking your project and module sdk.
On your module select F4 or Right click "Open Module Settings"
Check your SDK and Moduel SDK
I am sure that will resolve your problem.
Check your IDEA project settings and look if your JDK is configured properly.
I suggest you use the gradle idea plugin to create your IDEA project files, instead of using the import function of existing gradle projects into IDEA, since from my experience it gave me troubles. Also adding new jars via gradle and updating your IDEA project files via gradle seems more consistent.
I uploaded a build.gradle gist, which might give you a good start:
https://gist.github.com/1580234
It contains some explanatory comments.
Greets,
Jan