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'
}
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'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 want to implement Firebase Cloud Messaging into my Flutter application and i started to implement the Android part. I added the dependencies just like in the Firebase documentation, but now I'm getting gradle error when building my app:
The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.1.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
I'm not experienced at all with gradle, so I would appreciate some help^^
Here is app/build.gradle
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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.leodr.pguapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
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 {
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 'com.google.firebase:firebase-messaging:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
And here is the project build.gradle(if needed):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.0'
}
}
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
}
Downgrade the gms version on your build.gradle to
classpath 'com.google.gms:google-services:3.2.1'
write this at the bottom of app.gradle com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
hello I had the same problem but I fixed it by adding in buil.gradle, I hope and solve it
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:3.2.1'
}
I think, when you don't have latest version of GRADLE/SDK/ANDROID STUDIO and you use the latest firebase supports version then this type of error may be generate.
So for the solution you have to decrease the gms version to run with your SDK compatible versoin.
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.