For Gradle : 7.1.3 - Flutter Android build is failing - android

I recently downloaded android studio version to Android Studio Dolphin | 2021.3.1 Patch 1 and downloaded latest flutter and dart. At time of creating new flutter project it's giving build error.
flutter --version
Flutter 3.3.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e99c9c7cd9 (2 days ago) • 2022-11-01 16:59:00 -0700
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0

You have to specify a repository from which gradle can download the dependency.
Please, check your build.gradle file (application level) that contains google and mavenCentral repositories
Build script section:
...
buildscript {
repositories {
google()
mavenCentral()
}
...
}
All projects section:
...
allprojects {
repositories {
google()
mavenCentral()
}
...
}

Related

Flutter Android gradle plugin to version 3.2.0 or higher

I have already update the latest Android Gradle version but still showing the error when generating the signed bundle.
generating signed bundle requires you to update the android gradle plugin to version 3.2.0 or higher
Below i have share the version details.
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
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'
}
}
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
Android studio version
Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+0-b60-7772763 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 11.4
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: Dart (211.7817), org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40), io.flutter (66.0.1)
Flutter version
Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5f105a6ca7 (3 months ago) • 2022-02-01 14:15:42 -0800
Engine • revision 776efd2034
Tools • Dart 2.16.0 • DevTools 2.9.2
Flutter editor in Android Studio doesn't have proper lint check for Android project code. You might need to access the gradle settings using Android editor for the changes to be indexed and rebuilt. To access the Android project with proper lint check, it's better to open it via Tools > Flutter > Open Android module in Android Studio

Flutter error : Could not resolve com.google.android.gms:play-services-location:16.+, Status code 502 [duplicate]

This question already has answers here:
Could not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
(19 answers)
Closed 1 year ago.
Looks like Bintray library is down and I am not able to build my app. I tried a lot of solutions but none them worked.
A similar github issue is there which is already closed without any proper help.
Github link: https://github.com/flutter/flutter/issues/94400
This is the error I am getting :
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.google.android.gms:play-services-location:16.+.
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
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
Exception: Gradle task assembleDebug failed with exit code 1
android\build.gradle
buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
// jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
// jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
** flutter doctor -v **
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19044.1348], locale en-US)
• Flutter version 2.2.3 at C:\Users\PC\Documents\src\flutter
• Framework revision f4abaa0735 (5 months ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\PC\AppData\Local\Android\sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
[√] VS Code (version 1.62.3)
• VS Code at C:\Users\PC\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.25.0
[√] Connected device (3 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.93
• Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.43
• No issues found!
All my codes were right, the only problem was the location package which I replaced with geolocator package. Now it's working fine.
Only change!!
api 'com.google.android.gms:play-services-location:16.+'
to
api 'com.google.android.gms:play-services-location:16.0.0'

Flutter retuns error compiling hello world app

I am trying to run the "hello world" app that is generated when you create a new app. This is error that I keep getting when I try to run it in Visual Studio Code:
* What went wrong:
A problem was found with the configuration of task ':app:processDebugManifest' (type 'ProcessMultiApkApplicationManifest').
> File 'G:\Projects\flutter\brew_crew4\build\app\intermediates\merged_manifest\debug\out\AndroidManifest.xml' specified for property 'mainMergedManifest' does not exist.
* 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 39s
Exception: Gradle task assembleDebug failed with exit code 1
I'm using JDK 1.8.291 and Gradle 7.0
I'm running the latest verion of Flutter as of the date of this post (2.2.3). Here is the output of "flutter doctor". There are no issues whatosever! On my Mac that has the saem version of Gradle and JDK, I can run flutter apps without problems!
• Flutter version 2.2.3 at d:\WebProjects\utils\flutter
• Framework revision f4abaa0735 (7 days ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at D:\Android\Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = D:\Android\Sdk
• Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.4)
• Visual Studio at g:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.9.31205.134
• Windows 10 SDK version 10.0.19041.0
[✓] Android Studio
• Android Studio at D:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = D:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
[✓] VS Code (version 1.57.1)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.24.0
[✓] Connected device (4 available)
• Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64 • Android 10 (API 29) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version
10.0.19043.1052]
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124
• Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.64
• No issues found!
I have tried reinstalling the JDK and Android Studio twice.
UPDATE: This is the contents of my build.gradle file:
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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
}
Any help greatly appreciated!
SOLVED: Apparently, starting from Gradle 6.5, it stopped working well on drives formatted as exFAT. If you must have your project on an exFAT partitioned drive, downgrade the gradle plugin in build.gradle to 4.0.2:
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
and downgrade the gradle version in gradle.properties to 6.4.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip

Flutter camera 0.8.1 make error in gradle build

After I updated the camera plugin in my project to the latest version camera 0.8.1 It causes an error when I want to compile and build on the Android platform.
I tried to change the Gradle version to fix this problem, but I couldn't fix this problem.
I provided all of my log and important files here, please help me to fix my problem, if you have any example which shows the usage of the latest camera plugin or something else, please don't hesitate to add your answer...
1.build.gradle(app) :
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.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "ir.taleb.test_camera"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2.build.gradle(project) :
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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
}
3.pubspec.yaml :
name: test_camera
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
camera: ^0.8.1
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
4.flutter doctor --verbose :
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale
en-US)
• Flutter version 2.0.6 at /Users/taleb/Developer/flutter
• Framework revision 1d9032c7e1 (6 days ago), 2021-04-29 17:37:58 -0700
• Engine revision 05e680e202
• Dart version 2.12.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/taleb/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Users/taleb/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with
is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
To re-install see
https://guides.cocoapods.org/using/getting-started.html#installation for
instructions.
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 45.1.2
• Dart plugin version 193.7547
[✓] Connected device (3 available)
• SM A107F (mobile) • R9AM905ZREJ • android-arm • Android 10 (API 29)
• macOS (desktop) • macos • darwin-x64 • macOS 11.2.3 20D91
darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome
90.0.4430.93
! Doctor found issues in 1 category.
5.Error LOG:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':camera:extractDebugAnnotations'.
> Could not resolve all files for configuration ':camera:lintClassPath'.
> Could not find lint-gradle-27.1.0.jar (com.android.tools.lint:lint-gradle:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/27.1.0/lint-gradle-27.1.0.jar
> Could not find lint-27.1.0.jar (com.android.tools.lint:lint:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint/27.1.0/lint-27.1.0.jar
> Could not find lint-checks-27.1.0.jar (com.android.tools.lint:lint-checks:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-checks/27.1.0/lint-checks-27.1.0.jar
> Could not find lint-api-27.1.0.jar (com.android.tools.lint:lint-api:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-api/27.1.0/lint-api-27.1.0.jar
> Could not find intellij-core-27.1.0.jar (com.android.tools.external.com-intellij:intellij-core:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/intellij-core/27.1.0/intellij-core-27.1.0.jar
> Could not find kotlin-compiler-27.1.0.jar (com.android.tools.external.com-intellij:kotlin-compiler:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/27.1.0/kotlin-compiler-27.1.0.jar
> Could not find uast-27.1.0.jar (com.android.tools.external.org-jetbrains:uast:27.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/external/org-jetbrains/uast/27.1.0/uast-27.1.0.jar
> Could not find aapt2-proto-4.1.0-alpha01-6193524.jar (com.android.tools.build:aapt2-proto:4.1.0-alpha01-6193524).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/4.1.0-alpha01-6193524/aapt2-proto-4.1.0-alpha01-6193524.jar
* 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 37s
Exception: Gradle task assembleDebug failed with exit code 1

Flutter run release fails: Minimum supported Gradle version is 5.6.4. Current version is 5.6.2

When trying to run my app with flutter run --release it throws an error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Chris\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\device_info-0.4.2+1\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'device_info'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.6.2. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Chris\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\device_info-0.4.2+1\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.6.4-all.zip
If I remove this device_info plugin, I get the same error just pointing to Gradle current version to be 4.10.2 due to another plugin flutter_plugin_android_lifecycle.
I don't understand. I tried updating my gradle-wrapper.properties to
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Previously it was set to 5.6.2, but this changed nothing. Also tried with 4.10.2, but it equally just get's ignored.
I updated the gradle version in my build.gradle to
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
I created a new flutter project, just copied my pages and the pubspec... I tried in console, I tried with android studio. flutter clean, flutter build appBundle, deleting gradle versions, I tried everything I could think of or that I have read somewhere...
Nothing could help to get rid of this error, gradle insists that its current version is 5.6.2.
A new "virgin" flutter project however, I can run in release mode, without problems.
It appears these plugins will download their own gradle version. I could see it in Android Studio how an old gradle version is downloaded in contrary to the actual gradle version stated in my settings. Either way after 3 days with this, I'm running out of options and ideas.
Does anyone know how to solve this or to narrow the problem down? I also would be glad for an explanation on what's going on here.
My flutter doctor output:
[√] Flutter (Channel master, v1.17.1-pre.23, on Microsoft Windows [Version 10.0.18362.720], locale de-DE)
• Flutter version 1.17.1-pre.23 at C:\flutter
• Framework revision a2e6c30b44 (12 hours ago), 2020-04-03 20:26:01 -0700
• Engine revision 09bc1fc45e
• Dart version 2.8.0 (build 2.8.0-dev.19.0 e736495eb7)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\Chris\AppData\Local\Android\sdk
• Platform android-R, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 45.0.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2)
• VS Code at C:\Users\Chris\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.9.0
[√] Connected device (1 available)
• Lenovo A6020l36 • 32aac289 • android-arm64 • Android 5.1.1 (API 22)
• No issues found!
I found the problem.
It was a totally different plugin unique_identifier 0.0.3 that caused the error. After removing it, the app compiles dine again.
If you have a similar case: I had to test for every single package installed until I found it.

Categories

Resources