Could not find method compile() for arguments [project ':react-native-sqlite'] - 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.

Related

problem trying to integrate firebase to android studio

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
}

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

React Native build fails after add firebase setup

I need to set up my react-native app with firebase and I followed the firebase setup guide and after that rerun the app but it fails with giving me errors, I tried lots of solutions that available on the internet but still my issue is not fixed.
if anyone have got this issue before and fixed it already, could you please help me to fix this issue.
this is the error:
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not find com.google.android.gms:play-services-measurement:12.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
- https://jitpack.io/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.pom
- https://jitpack.io/com/google/android/gms/play-services-measurement/12.0.1/play-services-measurement-12.0.1.aar
Required by:
project :app > com.google.firebase:firebase-analytics:17.2.0
> Could not find com.google.android.gms:play-services-measurement-api:12.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
- https://jitpack.io/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.pom
- https://jitpack.io/com/google/android/gms/play-services-measurement-api/12.0.1/play-services-measurement-api-12.0.1.aar
Required by:
project :app > com.google.firebase:firebase-analytics:17.2.0
> Could not find com.google.android.gms:play-services-measurement-sdk:12.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- file:/home/iswan/.m2/repository/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/react-native/android/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- file:/home/iswan/works/office/xforce/xForceMobile/node_modules/jsc-android/dist/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
- https://jitpack.io/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.pom
- https://jitpack.io/com/google/android/gms/play-services-measurement-sdk/12.0.1/play-services-measurement-sdk-12.0.1.aar
Required by:
project :app > com.google.firebase:firebase-analytics:17.2.0
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "+"
}
repositories {
google()
maven { url "https://maven.google.com" }
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
maven { url "https://maven.google.com" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
jcenter()
maven { url 'https://jitpack.io' }
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "12.0.1"
}
}
}
}
}
#AjithMadhu I found the issue, it because of the below section. I hardcoded before a month ago and I didn't notice that one.
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "12.0.1"
}
}
}
}
well this is how I done. please refer this,
android/build.gradle
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
+ classpath 'com.google.gms:google-services:4.3.3' // check this line
}
android/app/build.gradle
dependencies {
+ implementation "com.google.android.gms:play-services-base:17.1.0"
+ implementation 'com.google.firebase:firebase-core:17.2.1'
+ implementation 'com.google.firebase:firebase-messaging:20.0.1'
}
android/
grade.properties
firebaseCoreVersion=17.2.1
firebaseMessagingVersion=20.0.1
MainApplication.java
+ import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
+ import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNFirebaseMessagingPackage());
packages.add(new RNFirebaseNotificationsPackage());
return packages;
}

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

Resources