I am trying to add Firebase Analytics to my Android Studio project.
I am getting the following error:
all firebase libraries must be either above or below 14.0.0
I have already been seeing this question that has a solution but I tried similar changes and is not working still.
Here is my (module: app) build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "my-application-id"
minSdkVersion 9
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.navercorp.pulltorefresh:library:3.2.0#aar'
}
}
dependencies {
compile 'com.google.firebase:firebase-core:15.0.0'
}
repositories {
maven {url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
apply plugin: 'com.google.gms.google-services'
And here is my (project) build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.3.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Thank you in advance for your help.
To solve this, please move the following line of code:
compile 'com.google.firebase:firebase-core:15.0.0'
In the above dependencies section and change it to:
compile 'com.google.firebase:firebase-core:16.0.1'
If you also want to use Analytics, please also add the following line of code:
com.google.firebase:firebase-analytics:16.0.1
To make it work, change also the followin line of code:
classpath 'com.google.gms:google-services:3.3.0'
to
classpath 'com.google.gms:google-services:4.0.1'
Related
I want to use Google architecture components in my app, but after updating android studio to version 3.1.1 when I add android.arch.lifecycle:extensions:1.1.1 dependency into app.gradle file, it will show Failed to resolve: support-fragment
My gradle version is 4.4
This is app gardle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "ir.apptori.myapplication"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "android.arch.lifecycle:extensions:1.1.1"
}
Please guid me how to fix it, Thanks
I had a similar error and changing the repositories order so that google() comes before jcenter() fixed it.
I had to change the order for the repositories within buildscript and allprojects in the top level build.gradle file.
Please see this commit:
https://github.com/kunadawa/ud851-Exercises/commit/9f6720ef4d52c71b206ddaa8477f2cf6e77a66f4
I also had to remove the maven url from the project build.gradle as in:
buildscript {
repositories {
google()
jcenter()
// maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
This now works for me.
add these two to build.gradle -> repositories
{
mavenCentral()
google()
}
and add to these are to allprojects
allprojects {
repositories {
mavenCentral()
google()
}
}
i add this line in build.gradle and fixed bug :
implementation 'androidx.fragment:fragment:1.2.5'
This just happened to me with a project I cloned from github.
I updated my SDK and buildtools and had to double check all the dependencies to match the buildToolsVersion and the compileSdkVersion from the project.
The error message wasn't very clear when I tried to sync the project, it only gave me a more explicit error when I tried to run and it failed.
Could not find support-fragment.jar (com.android.support:support-fragment:27.0.2).
Good Luck!
for a similar issue its solved by changing material implementation from alpha2 version to alpha 7 in the app build.gradle file
implementation 'com.google.android.material:material:1.1.0-alpha07'
After upgrading to Android Studio 3.0 I had some issues with gradle that I was able to fix checking on the developers website
However, I was not able to find how to fix the issue with the apply plugin: 'android-apt' I have tried several things such as removing it from the project gradle and add it to the app gradle as annotationProcessor 'com.neenbedankt.gradle.plugins:android-apt:1.8' . also removed the apt, etc, etc.
Anyway, Studio is complaining about it. Any help is greatly appreciated. Thanks!
// 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:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
ext {
supportLibVersion = '27.0.0'
firebaseLibVersion = '11.4.2'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
APP GRADLE
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
defaultConfig {
applicationId "xxxxxxxxxxxxxxxxxxxx"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
apply plugin: 'android-apt'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${supportLibVersion}"
.....
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
Do not use apt plugin, add the dependency like this:
compile "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
Reference
If you are in hurry you can disable that thing.
As per Document
If you are experiencing issues migrating to the new dependency
resolution strategy, you can restore behavior to that of Android
plugin 2.3.0 by setting includeCompileClasspath true. However,
restoring behavior to version 2.3.0 is not recommended.
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
}
And one more thing you have to define flavorDimensions "default" property in buildTypes tag in gradle file.
You can check more about this here.
I'm trying to update the google play services lib from 6.5.87 to 7.5.0 but after change the android version at the build.gradle:
I'm getting the following error:
I had read that this error is related to appcompat but I'm not using or including this lib.
This is my complete build.gradle:
import java.util.regex.Pattern
buildscript {
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// The Fabric Gradle plugin uses an open ended version to react quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric' // Fabric Gradle plugin, always after Android plugin
dependencies {
// 'jar' files in '/libs' folder
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services:6.5.87'
// Fabric
compile('com.crashlytics.sdk.android:crashlytics:2.+#aar') {
transitive = true;
}
}
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
Your mistake is u have changed Project label Gradle instead of App label.
Solution:
Put compile 'com.google.android.gms:play-services:6.5.87'
is App Label Gradel file put apply plugin: 'com.google.gms.google-services' as well.
Similarly
in Project label Gradle file put
classpath 'com.google.gms:google-services:1.3.0-beta1'
Example:
app Gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appifiedtech.androidgoogleplusapi"
minSdkVersion 15
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.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.5.0'
}
Project Label Gradle:
// 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:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
This is an old question which is irrelevant today. See Android developer's instruction. Applying Databinding to your projects is a lot easier now than four years ago.
As I am going over Android Data binding Guide from https://developer.android.com/tools/data-binding/guide.html. I have made sure I am running Android Studio 1.3 (canary version).
Following the guidelines, I get this error:
Gradle sync failed: could not find com.android.databinding:library:1.0-rc0
Has anyone else have the same problem? Thanks for your help.
App build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
}
}
allprojects {
repositories {
jcenter()
}
}
Module build.graddle
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'android-apt'
def AAVersion = '3.3'
def MyProject = 'com.commonsware.android.frw.filesdemo'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
mavenCentral()
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "$MyProject"
}
}
android {
compileSdkVersion 22
buildToolsVersion "22"
defaultConfig {
applicationId "$MyProject"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
}
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile "com.squareup:otto:1.3.6"
compile "commons-io:commons-io:+"
compile 'com.fasterxml.jackson.jr:jackson-jr-all:2.5.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
I had this problem and solved it by adding "jcenter" under allprojects.repositories in my top-level build.gradle (I had been using mavenCentral).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.databinding:dataBinder:1.0-rc1'
}
}
allprojects {
repositories {
mavenCentral()
jcenter() // <=== *** Adding this fixed it ***
}
}
I got errors when I sync build.gradle files.
Error:Failed to resolve: com.android.databinding:library:1.0-rc0
Error:Failed to resolve: com.android.databinding:adapters:1.0-rc0
And I finally found the solution.
dependencies {
// instead of the below pathes...
//classpath "com.android.tools.build:gradle:1.3.0-beta2"
//classpath "com.android.databinding:dataBinder:1.0-rc0"
// I used the following classpathes.... It works!
classpath "com.android.tools.build:gradle:1.3.+"
classpath "com.android.databinding:dataBinder:1.+"
}
By looking at your error Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0 you should try this instead,
classpath "com.android.databinding:dataBinder:1.0-rc1"
To use DataBinding follow all these steps.
Update your Android Studio to Android Studio 1.3 version.
To set up your application to use data binding, add data
binding to the class path of your top-level build.gradle file,
right below "android".
dependencies {
classpath "com.android.tools.build:gradle:1.3"
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
Then make sure jcenter is in the repositories list for your projects
in the top-level build.gradle file.
allprojects {
repositories {
jcenter()
}
}
In each module you want to use data binding, apply the plugin right
after android plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
Clean and build your app.
Complete code
top-level build.gradle file,
// 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:1.3'
classpath "com.android.databinding:dataBinder:1.0-rc1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
module-level build.gradle file,
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.packagename"
minSdkVersion 15
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.android.support:appcompat-v7:22.2.1'
}
For more detail Data Binding Guide.
For Complete demo Data Binding Android
Make sure you have Android Studio 1.3 or higher
Your project build.gradle should look something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And your module build.gradle should look something like this:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.my.appId"
minSdkVersion 15
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'])
}
I had a problem where I was targeting M Preview so nothing worked. Once I changed the build tools to 22.0.1, and the targetSdkVersion to 22, everything worked.
I had the same issue and solved it by updating android sdk tools to 24.3.3.
Update for latest Android Studio & latest Gradle
You don't need to add databinding:dataBinder dependency now. Just enable dataBinding in app level build.gradle in android tag.
android
{
...
dataBinding {
enabled = true
}
...
}
As the Documentation said
To use data binding, Android Plugin for Gradle 1.5.0-alpha1 or higher
is required.
I have added the following line to 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:1.5.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
}
and then add the :
dataBinding {
enabled = true
}
to your build.graddle module app like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "gujarat.databinding"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
Please, try to change classpath to 'com.android.tools.build:gradle:1.3.0-beta2' and set buildToolsVersion "23 rc2".
Don't forget to update SDK packages via SDK manager before doing that.
Here you can find more information about Android Preview SDK: Set Up the Preview SDK
I had an identical issue, and solved it by removing the plugin for android-apt. Not sure what's conflicting there, but something is.
You should update your SDK and It will resolve this issue.
You should add
classpath 'com.android.tools.build:gradle:1.3.0'
classpath "com.android.databinding:dataBinder:1.0-rc0"
build.grade which in project Directory.
then Sync the gradle
Sync your project after adding classpath
I've got a project in Android Studio and I can't quite seem to figure out this gradle issue. My app structure is as follows:
app (module) relies on crashlib (module), crashlib relies on an AAR from an external repository which I have listed in crashlib's gradle file.
The problem is that when I go to compile the app the default repository (https://jcenter.bintray.com/) is used instead of the one defined in crashlib, so the build fails. If I add the repository definition from crashib to the app module then it builds successfully, but it's not ideal. I can also build crashlib successfully on its own.
Here is the crashlib build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
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.android.support:appcompat-v7:22.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar')
}
Any ideas how to get the repository to be used when building the app?
In your buildscript block you should use somenthing like this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}