Error with Google Maps Flutter in Android Studio - android

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

Related

What version of Gradle plugin do I use in my Android app?

I have the following build.gradle in my Android app:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
}
}
repositories {
google()
mavenCentral()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.google.android.gms:play-services-ads:21.3.0'
implementation "com.android.billingclient:billing:4.0.0"
}
and get a warining:
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33
This Android Gradle plugin (7.0.2) was tested up to compileSdk = 31
This warning can be suppressed by adding
android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties
The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33
But when I try to use Gradle plugin 7.4 I get this:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android-build'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.4.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.4/gradle-7.4.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.4/gradle-7.4.pom
Required by:
project :
* 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
with 7.2 I get this:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\dev\repos\examples\src\LinesGame\build-LinesGameQt-Android_Qt_6_4_0_x86_64_debug_Clang_x86_64-Debug\android-build\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'android-build'.
> Failed to apply plugin 'com.android.internal.version-check'.
> Minimum supported Gradle version is 7.4. Current version is 7.2. If using the gradle wrapper, try editing the distributionUrl in D:\dev\repos\examples\src\LinesGame\build-LinesGameQt-Android_Qt_6_4_0_x86_64_debug_Clang_x86_64-Debug\android-build\gradle\wrapper\gradle-wrapper.properties to gradle-7.4-all.zip
* 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
What is happening?
EDIT1
If I spefify 7.3.1 version in build.gradle I get the following strange error message:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\dev\repos\examples\src\LinesGame\build-LinesGameQt-Android_Qt_6_4_0_x86_64_debug_Clang_x86_64-Debug\android-build\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'android-build'.
> Failed to apply plugin 'com.android.internal.version-check'.
> Minimum supported Gradle version is 7.4. Current version is 7.2. If using the gradle wrapper, try editing the distributionUrl in D:\dev\repos\examples\src\LinesGame\build-LinesGameQt-Android_Qt_6_4_0_x86_64_debug_Clang_x86_64-Debug\android-build\gradle\wrapper\gradle-wrapper.properties to gradle-7.4-all.zip
* 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
What can it be?
Version 7.4 of the Android Gradle plugin doesn't exist, the latest stable version is 7.3.1, as you can see in the Google's Maven repo index. Other versions you could use are 7.4.0-beta02 and 8.0.0-alpha05.

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

Problems reading data from Binary store .I tried lots of solution but not working please help me

'''Launching lib/main.dart on vivo 1907 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':onesignal_flutter:generateDebugRFile'.
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
1, 17.3.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.onesignal:OneSignal:3.16.0 -> com.google.firebase:firebase-messaging#[10.2.1, 17.3.99], but fire
base-messaging version was 17.3.4.
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 'onesignal_flutter' which depends onto com.google.firebase:firebase-messaging#{stric
tly 17.3.4}
-- Project 'app' depends on project 'onesignal_flutter' which depends onto com.onesignal:OneSignal#{strictly 3.16.0}
-- Project 'app' depends on project 'onesignal_flutter' which depends onto com.onesignal:OneSignal#3.16.0
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 = true }" to your bu
ild.gradle file.
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 51s
Exception: Gradle task assembleDebug failed with exit code 1
'''

Flutter google maps android build failed

I tried to add google maps to my flutter project
dependencies:
geolocator: ^2.1.0
google_maps_flutter:
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="my key was here"/>
The problem is that after adding this dependence, every running - build failed with this message:
FAILURE: Build failed with an exception.
* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
project ':google_api_availability' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
of course, I tried to change the gradle version to another one, as it advised in other posts, but it didn't help.
I really don’t know what the problem is, because without maps the project compiles, I checked.
You have to upgrade the geolocator package which depends on google_api_availability by running the command flutter pub upgrade

Android Gradle Issue - Flutter / Dart

I have a problem with my Gradle Sync.
I use IntelliJ and Android Studio to build a Flutter / Dart App.
I added 2 new dependencies and now i have an issue with Gradle.
In Android Studio all works fine (The Gradle Sync finishes without failures or warnings), but in IntelliJ it is not working.
* Error running Gradle: Exit code 1 from: C:\Users\stesc\Documents\Programming\timecoder-flutter\android\gradlew.bat app:properties: NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\stesc\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
BUILD FAILED
Total time: 4.669 secs
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\stesc\Documents\Programming\timecoder-flutter\android\build.gradle' line: 25
* What went wrong: A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'. Finished with error: Please review your Gradle project setup in the android/ folder.
> A problem occurred configuring project ':shared_preferences'.
> Could not resolve all dependencies for configuration ':shared_preferences:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :shared_preferences
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
1. Update your gradle version from project -> android -> build. For me :
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
2. Use latest sdk tool version
3. Open terminal from Tools->Flutter and run these following commands
flutter upgrade
flutter doctor
Make your allpojects->repositories same like buildscript->repositories
If the problem still persists check if your project and shared_preferences both uses the same gradle version. If not, then you may need to make few changes in either your project or in shared_preferences project.
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.0"
}
}
}
}
It fixed for me by adding this to my build.gradle in android folder.
yaa It had solved for me..!
Just go to flutter sdk folder and go to this path \flutter\packages\flutter_tools\gradle\flutter.gradle
and in flutter.gradle file change from this code
buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
I had the same problem and solved it too.
Perhaps, will be useful for someone.
This was my problem:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/abc/Desktop/user/project/android/app/build.gradle' line: 14
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.4.1. If using the gradle wrapper, try editing the distributionUrl in
/Users/abc/Desktop/user/project/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-all.zip
* 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 8s
Command: /Users/abc/Desktop/user/project/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
I went to gradle-wrapper.properties and changed this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
The problem was solved.

Categories

Resources