Gradle not compiling for Firebase Cloud Messaging - android

I noticed that Firebase APIs have upgraded from v 9.0.0 to v 9.0.1 and so decided to change that.
However it is not getting noticed.
Here is the Error in Gradle Logcat
Error:(25, 13) Failed to resolve: com.google.firebase:firebase-messaging:9.0.1
Error:(26, 13) Failed to resolve: com.google.firebase:firebase-core:9.0.1
And here are my Gradle Files
Build.Gradle-> App
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.lifeline.applicationgreat"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.firebase:firebase-core:9.0.1'
}
apply plugin: 'com.google.gms.google-services'
Build.Gradle-> Project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can Anyone tell whats the Error or if I am Missing anything.
Also Is there any requirement of Firebase-core for Cloud Messaging?
Thanks

You have to update/install Google Repository, revision 27
Check this answer: firebase setup on android

I had the same issue with "com.google.firebase:firebase-ads:9.0.1", what I did was install from de SDK Manager Google Repository Extra.

You'll need to go to the Android SDK manager and check for updates - you should see an update to the Google Play services SDK which will resolve these dependencies.

For mac os users, a part from updating your SDK, if you have installed the ADK with and without brew, be sure to check that the path for your ADK in Android studio is the correct one. My problem was that android studio reverted to the old path on its own.

Related

Gradle Error in Android Studio upon first installing

I recently began using Android Studio and was trying to follow the "First App" tutorial (https://developer.android.com/training/basics/firstapp/). When I create a new project in Android Studio, however, I am almost immediately greeted by this error
ERROR: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'.
I've tried deleting my ~/.gradle directory and invalidating caches before restarting android studio but this doesn't fix the issue. I've also tried downloading gradle and using a local distribution of it, as well as playing with the version both locally and the default gradle wrapper version found in the cradle-wrapper.properties file. I tried both using the most current distribution (6.0.1) as well as going back a few versions and nothing has helped.
I am running on Mac OS 10.13.6 and Android Studio 3.5.2, using a Nougat distribution for my project (API 24, Android 7.0).
Edit: When I open the event logger, this is what I see:
11:18 Gradle sync started with single-variant sync
11:18 Gradle sync failed: ch.qos.logback.classic.Logger cannot be cast to org.gradle.api.logging.Logger (2 s 7 ms)
11:18 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN
Edit:
build.gradle files
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "eecs285.proj4.nortoncofirstapp"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Android Studio: Restore Project Backup after Gradle Update

After opening an older project for the first time after a few weeks/months (very busy with work) Android Studio asked me to upgrade to the latest gradle plugin.
Gradle Upgrade promt
I didn't really think anything of it and hit "Update". After Gradle finished updating and syncing I noticed that most of my layout and java class files vanished. They're simply gone.
However, in my project's directory a folder called "projectFilesBackup" appeared. I assume that restoring the backup contained in this folder might bring my missing files back.
projectFilesBackup Folder
So my question is: Does anyone know how I actually tell Android Studio to restore to the backup? It only contains an ".idea" folder which contains "workspace.xml". Any help would be greatly appreciated.
I've already tried using "Local History" to undo any changes done on the day of the Gradle Update as detailed in this SO post.
Edit:
As requested my build.gradle files:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath "io.realm:realm-gradle-plugin:1.2.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.tools.awesome.cs.grademanager"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'io.realm:android-adapters:1.3.0'
}
Change the realm-gradle-plugin to the most dated one and see if it brings up the files again.
classpath "io.realm:realm-gradle-plugin:2.0.2"

Framework code "can't resolve symbols" in Android Studio

I am trying to debug through library code in Android Studio. But it shows unresolved symbols, i.e., red lines at lots of places.
My app build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.kuldeep.customview"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
My project build.gradle file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You're looking at the code for TextView, which is an Android platform class and not part of your app. Platform classes can refer to other "package private" classes that are not part of the visible API for an app. Android studio provides for you the ability to view platform source code like this so you can see how it works, but you can't make changes to it and you don't get access to all the actual compiled classes in the SDK.
The short story is that is regular and expected. If you were seeing this for your own app code (not platform classes or add-on libraries) then you'd have something to be concerned about.
2 possible reasons:
Gradle not synced.
Try syncing your gradle files using Gradle Sync.
SDK not updated.
Make sure your SDK is updated and that you have all the extra packages that you need installed. You can do that using SDK Manager.

Google Sign-in button error in Android

I try to include Google sign-in button in my android app by following steps:
1) Including the button:
<com.google.android.gms.common.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
2) Editing Top-level build file
classpath 'com.google.gms:google-services:1.5.0-beta2'
3) Editing App-level build file
apply plugin: 'com.google.gms.google-services'
Now I am getting error in button UI as
Blockquote
The following classes could not be found:
- com.google.android.gms.common.SignInButton (Fix Build Path, Create Class)
Please help me solve this issue!
First of all we need to clarify that you should have 2 build.gradle files. One of them is a project-level file and the other one is an app-level Gradle file:
These files should look like this:
Project: StackOverlfow build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module: app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.package"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-auth:8.4.0'
}
If you don't have Google Play Services installed, please do the following:
Go to Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK.
You'll see on the bottom part a "Launch Standalone SDK Manager".
Click that and you'll have the standalone SDK Manager window opened.
Scroll all the way down to "Extras" pick "Google Play Services" and hit update.
This will install the proper play services packages. Once done, go back to the Android Studio and re-sync your Gradle file.
Take a look at my question over here - Android - Google Login and Play Services version incomptablity
You need:
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
classpath 'com.google.gms:google-services:2.0.0-alpha5'
and
compile 'com.google.android.gms:play-services-auth:8.4.0'
Also, Google's sample here was helpful to me
https://github.com/googlesamples/google-services/blob/master/android/appinvites/app/build.gradle

Android Studio Gradle does not download maven depedencies

I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.

Categories

Resources