I'm trying to install the firebase database for real time database in my project but im facing an exception every time I try to run.
here's the exception I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find firebase-database-19.6.0.aar (com.google.firebase:firebase-database:19.6.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-database/19.6.0/firebase-database-19.6.0.aar
and here's the firebase database version along with the firebase core version in my pubspec:
firebase_core: ^0.7.0
firebase_database: ^6.0.0
and here's my android/build.gradle file:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
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.8'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and these are my dependencies in my app/build.gradle:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
}
I've tried upgrading the gradle version along with the google service version to no avail I tried (flutter clean, deleting the project and coping everything to a new project) I've also tried installing this package in my other projects and it worked fine but it seems the issue is from something else in this project.
The problem was that the gradle version in the gradle/wrapper file was new and doesn't have this file (firebase-database-19.6.0.aar).
So this is what it was:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
and this is it now:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
Related
I trying integrate FireBase in Android Studio.
But, when i get to this point:
allprojects{
repositories
{
google()
}
}
They give me:
Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
But, if i donĀ“t write these repositories, i can sync.
enter image description here
enter image description here
Does anyone know how to fix this?
Thanks
First, check in your gradle scripts,
if you have settings.gradle file then do like below in settigs.gradle
pluginManagement {
repositories {
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Schedule Post"
include ':app'
if you don't have settings.gradle then your build.gradle(Project level) look like below code.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After updating the Android Studio to latest while connecting to the Firebase below error is coming.
Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
Project Gradle:-
buildscript {
ext.kotlin_version = "1.4.32"
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Finally, after googling i found the solution. I have removed below line from Module Gradle and it worked.
testImplementation 'junit:junit:'
I am trying to set up Firebase crashlytics to my flutter app. I have followed the steps from https://blog.codemagic.io/practical-guide-flutter-firebase-codemagic/ and works fine when I run in local. However, I see a failure using the CI/CD tool - Codemagic.
== Initializing Gradle project /Users/builder/clone/android/app/build.gradle ==
Picked up _JAVA_OPTIONS: -Xmx3g
FAILURE: Build failed with an exception.
Where:
Build file '/Users/builder/clone/android/build.gradle' line: 7
What went wrong:
A problem occurred evaluating root project 'android'.
Could not find method maven() for arguments [build_8np9gq8hl982yq6pq0eovgcan$_run_closure1$_closure3#6b63e6ad] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Not sure of any solution. Reached out to codemagic support on slack!
This is now my app/android/build.gradle file looked like:
buildscript {
repositories {
google()
jcenter()
}
maven {
url 'https://maven.fabric.io/public'
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Expected result: The build should happen fine on codemagic
With support from Mikhail at code magic, below is the solution:
maven should be inside repositories
https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:declaring_custom_repository
Like below:
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
}
I am getting a google play services error in android studio and i am using flutter. I have tried various solutions but nothing seems to work.
I have tried to change the version of googleplayservices but its the same.
Failed to capture fingerprint of input files for task
':app:checkDebugClasspath' property 'compileClasspath' during up-to-date
check.
> In project 'app' a resolved Google Play services library dependency
depends on another at an exact version (e.g. "[15.0.
1]", but isn't being resolved to that version. Behavior exhibited by the
library will be unknown.
Dependency failing: com.google.android.gms:play-services-flags:15.0.1 ->
com.google.android.gms:play-services-basement#[
15.0.1], but play-services-basement version was 16.0.1.
The following dependencies are project dependencies that are direct or have
transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends on project 'firebase_auth' which depends onto
com.google.firebase:firebase-auth#16.0.2
-- Project 'app' depends on project 'firebase_core' which depends onto
com.google.firebase:firebase-core#16.0.4
-- Project 'app' depends on project 'cloud_firestore' which depends onto
com.google.firebase:firebase-firestore#17.1.1
-- Project 'app' depends on project 'firebase_storage' which depends onto
com.google.firebase:firebase-storage#15.+
-- Project 'app' depends on project 'google_sign_in' which depends onto
com.google.android.gms:play-services-auth#16.0.1
For extended debugging info execute Gradle from the command line with
./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-
services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding
"googleServices { disableVersionCheck = false }" to your b
uild.gradle file.
build.gradle(app)
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with
flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.news"
minSdkVersion 16
multiDexEnabled true
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release`
works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
build.gradle/project
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
ext {
global_version_firebase = '16.0.+'
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
pubspec.yaml
name: news
description: 'A new Flutter application.'
version: 1.0.0+1
environment:
sdk: '>=2.0.0-dev.68.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: null
share: null
connectivity:
url_launcher:
cloud_firestore:
rxdart:
firebase_auth: ^0.5.19
google_sign_in:
date_format:
intl:
firebase_storage: ^0.3.7
image_picker:
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/logo.jpg
- images/fb.jpg
- images/back.jpg
- images/google.jpg
please help me to solve this error.
Thank you
the issue actually stems from this one dependency here:
Project 'app' depends on project 'firebase_storage' which depends onto
com.google.firebase:firebase-storage#15.+
this means, that pubspec.yaml needs this one dependency updated:
firebase_storage: ^1.0.4
as the documentation states for 1.0.4 from Oct 12, 2018 bump Android dependencies to latest.
react-native-cli: 2.0.1
react-native: 0.42.0
npm :3.5.2
I install sqlite on react native using this tutorial:
https://github.com/remobile/react-native-sqlite
when I'm done I executed this command :
react-native run-android
I have this error :
Cannot parse yarn version: 0.22
Scanning 547 folders for symlinks in /home/sofiane/projet/sql/node_modules (6ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* Where:
Build file '/home/sofiane/projet/sql/android/build.gradle' line: 9
* What went wrong:
A problem occurred evaluating root project 'sql'.
> Could not find method compile() for arguments [project ':react-native-sqlite'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
build.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:2.2.3'
compile project(':react-native-sqlite')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
You should configure <name-project>/android/app/build.gradle' not <name-project>/android/build.gradle'.
In my case the structure of the gradle file was the problem, i accidetally duplicated the dependencias on allprojects session
from :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
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 {
jcenter()
google()
}
dependencies { //=> duplicated
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "io.realm:realm-gradle-plugin:6.0.1"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
to
buildscript {
ext.objectboxVersion = '2.1.0'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "io.realm:realm-gradle-plugin:6.0.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Hope this helps someone.