problem trying to integrate firebase to android studio - firebase

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
}

Related

Kotlin error Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync

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:'

Could not find firebase-database-19.6.0.aar

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

I am trying to do a game in libgdx using firebase but when I try to add Firebase it keeps giving me these errors

These are the errors :
.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method classpath() for arguments [com.google.firebase:firebase-database:19.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
And this is my apps build.gradle file
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-database:19.3.0#aar'
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "epl0"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
Replace the classpath with implementation:
implementation 'com.google.firebase:firebase-database:19.3.0'
See: Firebase Realtime Database Docs

Dependency issue when linking app to Firebase Crashlytics - maven/android/flutter

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'
}

Could not find method compile() for arguments [project ':react-native-sqlite']

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.

Resources