Flutter project in Android Studio gradle issue - android

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.1) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution
* 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.
BUILD FAILED in 5s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Finished with error:
Gradle task assembleDebug failed with exit code 1

Try below inside your build.gradle
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { it ->
if (it.requested.group == 'androidx.appcompat'
&& !it.requested.name.contains('appcompat') ) {
it.useVersion "1.0.2"
}
}
}
}
Or
Change androidx.appcompat:appcompat to version 1.0.2 inside your dependencies {} block.

Related

React Native Navigation : A problem occurred evaluating project ':react-native-navigation'

Bug Report
I've started learning React Native Navigation and I failed to launch the app with the implementation of basic navigation code.
Steps to reproduce
Run : npm install --save react-native-navigation.
Write the code of basic navigation.
Run : npx react-native start.
Run : npx react-native run-android.
Expected Behaviour
Current Behaviour
alaeddine#Ala-Dev:~/Apps/GitaApp$ npx react-native run-android
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Starting JS server...
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
at makeError (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I got the same error, and this is how i solved my problem,
step-1) npm install --save react-native-navigation
step-2) npx rnn-link
if step-2 still throws erros, then follow the Manual installation to make changes in your project manually provided by the documentation:
->iOS. https://wix.github.io/react-native-navigation/docs/installing#ios
->Android. https://wix.github.io/react-native-navigation/docs/installing#android
step-3) write the code of basic navigation
step-4) Run: npm start
step-5) Run: npm run android (for androids)

Why I am getting this error after Flutter Run?

I am getting the following Build failed with exception after I run my flutter project.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.1-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.1)
Go to the documentation to learn how to Fix dependency resolution errors.
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 26s
Running Gradle task 'assembleDebug'... 208.9s
Exception: Gradle task assembleDebug failed with exit code 1
I am currently using Flutter's latest version that is Version 2.10.1. Also in my project, I used the 'better_player' pub package.
Please give me a solution to this.
Add following dependency in app/build.gradle in dependencies at the end of the file -
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
Example -
dependencies {
...
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
}
First : if you are using video_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
Second : if you are using better_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
Third : if you are using the both video_player & better_player
you should downgraded video_player version to 2.1.12 in pubspec.yaml

BUILD FAILED in 3s Command: D:\Flutter\myfarmer\android\gradlew.bat app:properties

My code working perfectly before I will be add cloud firestore plugin but after I will be added this plugin and i get this error
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "D:\Flutter\myfarmer\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Flutter\myfarmer\android\app\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
Command: D:\Flutter\myfarmer\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.```
in your gradle make sure you are using google the old google-services 4.2.0
in android/build.gradle
dependencies {
...
classpath 'com.google.gms:google-services:4.2.0'
...
}
update flutter or use other version of gradle by changing the class path in my case this was worked
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
hope it helps you

Android dependency 'androidx.core:core' has different version for the compile (1.0.0-rc01) and runtime (1.0.2) class path

What went wrong:
Execution failed for task ':app:preDebugBuild'.
Android dependency 'androidx.core:core' has different version for the compile (1.0.0- rc01) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution
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.
Get more help at h../help.gradle.org
BUILD FAILED in 1s
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See for more information on the problem and how to fix it.
Finished with error: Gradle task assembleDebug failed with exit code 1

Error with Google Maps Flutter in Android Studio

I try to add google maps on flutter, I added the following dependence:
dependencies:
google_maps_flutter: ^0.5.17
and its respective api key in android and ios.
But when running the project it marks the following:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.google.android.gms:play-services-tasks' has different version for the compile (15.0.1) and runtime (16.0.1) classpath. You should manually set the same version via DependencyResolution
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Finished with error: Gradle task assembleDebug failed with exit code 1
and try to add the dependencies manually in buil.gradle
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
}
and this in build.gradle in project level
apply plugin: 'com.google.gms.google-services'
but still with the same.
You probably have to migrate your project to AndroidX. I had a similar issue in my project.
Open you Android folder in Android studio, go to File -> Sync Project With Gradle Files and then Refactor -> Migrate to AndroidX

Categories

Resources