So I was building this app where I want to get the current location for this I used the package geolocator from flutter link -> https://pub.dev/packages/geolocator
Before I used this package my app worked fine but after I constantly get this error:
FAILURE: Build failed with an exception.
* Where:
Script 'D:\School\Academiejaar 3\Semester 1\Mobile Applications\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\School\Academiejaar 3\Semester 1\Mobile Applications\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 12s
Running Gradle task 'assembleDebug'... 14.7s
Exception: Gradle task assembleDebug failed with exit code 1
My pubspec.yaml looks lik this:
name: assistly
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=2.18.1 <3.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
provider: ^6.0.3
flutter_svg: ^0.18.0
vibration: ^1.7.5
highlight_text: ^0.7.2
avatar_glow: ^1.2.0
geolocator: ^9.0.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/icons/
- assets/images/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
The error is concerning the package: geolocator: ^9.0.2
my build.gradle looks like this:
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 33
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
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 "com.example.assistly"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
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
}
}
}
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-location:20.0.0'
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
this is the output of flutter doctor -v:
[√] Flutter (Channel stable, 3.3.3, on Microsoft Windows [Version 10.0.22000.978], locale en-GB)
• Flutter version 3.3.3 on channel stable at D:\School\Academiejaar 3\Semester 1\Mobile Applications\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18a827f393 (5 days ago), 2022-09-28 10:03:14 -0700
• Engine revision 5c984c26eb
• Dart version 2.18.2
• DevTools version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\david\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Users\david\AppData\Local\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.6)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.0.32126.317
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.3)
• 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
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.2
• 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
[√] VS Code (version 1.71.2)
• VS Code at C:\Users\david\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.48.0
[√] Connected device (4 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.978]
• Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.54
• Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.53
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I have tried almost everything I found on stackoverflow, github, ...
such ass flutter clean
flutter pub get
I have tried rebuilding my gradle also downgrading flutter
All help is very welcome and I look forward to what you all find
If you need more information please let me know
I also had this kind of issue. Mine was with awesome_notifications after I had upgraded flutter.
I had to swap it out for local_notifications. Try replacing geolocator.
Related
We are trying to integrated Firebase_crashlytics in our App but because our App is built on an older version of Flutter (it doesn't support Null Safety) so we can't use the latest version. Then we decided to integrate version 2.7.1 or lower but the pubspec.lock file always resolves the version to 2.9.0 which is null safe and it throws build error for our App not being null safe.
Can anybody guide me as to what should I do or not do in this regard?
This is our Pubspec.yaml,
name: ------
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# ios
version: 0.1.1+1
# android
#version: 0.1.1+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependency_overrides:
firebase_core_platform_interface: 4.2.0
dependencies:
flutter:
sdk: flutter
# braintree_device_data:
# path: ../braintree_device_data
flutter_braintree:
path: ./flutter-braintree-master
onesignal_flutter:
path: ./flutter-onesignal
# flutter_facebook_auth:
# git:
# url: https://github.com/darwin-morocho/flutter-facebook-auth.git
# ref: master
# path: facebook_auth/
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
get: ^4.1.2
carousel_slider: ^3.0.0
email_validator: ^2.0.1
tab_indicator_styler: ^1.0.0
flutter_rating_bar:
flutter_staggered_grid_view: ^0.3.4
dotted_border: ^2.0.0
http: ^0.13.1
shimmer: ^2.0.0
flutter_slidable: ^0.6.0
google_sign_in: ^5.0.3
# flutter_facebook_auth: ^3.5.2 #// used as old facebook auth but due to an update we cant use it anymore
# flutter_facebook_auth: ^4.4.1+1 #// use this if you're using mac with an intel chip or the team is big
flutter_facebook_auth: ^5.0.7
sign_in_with_apple: ^3.2.0
sqflite: ^2.0.0+3
google_place: ^0.4.0
shared_preferences: ^2.0.6
nuts_activity_indicator: ^0.1.1
graphql_flutter: ^5.0.0
# flutter_braintree: ^2.0.0
flutter_html: ^2.2.1
equatable: ^2.0.3
pull_to_refresh: ^2.0.0
badges: ^2.0.1
image_picker: ^0.8.4+1
# image_picker: ^0.8.6 // requires gradle to be updated to 7.2 which may break some packages and gradle 7.2 doesn't work with OneSignal
firebase_core: ^1.6.0
firebase_analytics: ^8.3.3
firebase_performance: ^0.6.0+2
# firebase_performance: ^0.8.3+3
# url_launcher: ^6.0.10
# url_launcher: ^6.1.7
url_launcher: ^6.1.5
dio: ^4.0.0
flutter_svg: ^0.22.0
syncfusion_flutter_datepicker: ^19.3.45
flutter_typeahead: ^3.2.1
lottie: ^1.2.1
google_fonts: ^2.1.0
flutter_screenutil: ^5.0.0+2
app_tracking_transparency: ^2.0.2+1
# new_version: ^0.3.1
new_version_plus: ^0.0.1+4
uni_links: ^0.5.1
# app_links: ^2.2.0
app_links: ^3.4.1
flutter_phoenix: ^1.0.0
device_info_plus: ^4.0.0
path_provider: ^2.0.11
permission_handler: ^10.0.0
pusher_channels_flutter: ^2.0.1
intl: ^0.17.0
social_share: ^2.2.1
share_plus: ^4.5.3
upgrader: ^4.7.0
photo_view: ^0.14.0
file_picker: ^4.6.1
flutter_native_splash:
multi_image_picker2: ^5.0.2
# firebase_crashlytics: ^2.5.2
# cloudflare: ^1.3.0+11
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons:
flutter_native_splash:
color: "#ffffff"
image: assets/images/logo.png
flutter_icons:
android: true
ios: true
image_path: "assets/images/launcher_icon.png"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
- assets/JSON/
- assets/JSON/No_Message/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Mulish
fonts:
- asset: assets/fonts/Mulish-Regular.ttf
weight: 400
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
This is the result of Flutter doctor -v,
MacBooks-MacBook-Pro:marketplace-mobile-app macbookpro$ flutter doctor -v
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.6.3 21G419 darwin-x64, locale en-PK)
• Flutter version 2.10.4 at /Users/macbookpro/src/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c860cba910 (11 months ago), 2022-03-25 00:23:12 -0500
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/macbookpro/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/macbookpro/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• 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 11.0.12+0-b1504.28-7817840)
[✓] Connected device (2 available)
• Infinix X6811 (mobile) • 07363251BU000513 • android-arm64 • Android 11 (API 30)
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Okay, a little update.. The issue is resolved.
What we did:
flutter pub cache repair
flutter clean
flutter pub get
Invalidate Cache and Restart (Android
Studio)
It wasn't working yesterday but somehow today when we restarted the Mac and ran the same commands it Worked.
I have been facing this issue after I reset the Android Emulator as it got hanged while development so I just wiped the data. And since then I am facing this issue only for this specific project while for other projects they are working fine.
🔴 Error Logs
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling
software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
FAILURE: Build failed with an exception.
* Where:
Script 'D:\flutter2\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\flutter2\bin\flutter.bat'' finished with non-zero exit value 1
* 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
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 9.9s
Exception: Gradle task assembleDebug failed with exit code 1
🩺 Flutter doctor
[√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19043.1165], locale en-US)
• Flutter version 2.2.0 at D:\flutter2
• Framework revision b22742018b (4 months ago), 2021-05-14 19:12:57 -0700
• Engine revision a9d88a4d18
• Dart version 2.13.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Hamza\AppData\Local\Android\sdk
• Platform android-30, 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.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• 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
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] VS Code (version 1.59.1)
• VS Code at C:\Users\Hamza\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.25.0
[√] Connected device (3 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.78
• No issues found!
🗃 pubspec.yaml
name: donation_app
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.11.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
# other packages
font_awesome_flutter: ^9.1.0
syncfusion_flutter_sliders: ^19.2.55
charts_flutter: ^0.11.0
carousel_slider: ^3.0.0
bottom_navy_bar: ^6.0.0
share: ^2.0.4
screenshot: ^1.2.1
path_provider: ^2.0.2
permission_handler: ^8.1.4+1
image_picker: ^0.7.5+3
flutter_svg: ^0.22.0
datetime_picker_formfield: ^2.0.0
# analytics
amplitude_flutter: ^3.2.1
# firebase
firebase_auth: ^3.0.1
firebase_core: ^1.4.0
firebase_storage: ^10.0.1
cloud_firestore: ^2.4.0
# local storage
shared_preferences: ^2.0.6
# encryption
flutter_dotenv: ^5.0.0
# stripe
webview_flutter: ^2.0.8
dio: ^4.0.0
js: ^0.6.3
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/
- assets/events/
- assets/logo/
- assets/orgs/
- .env
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Comfortaa
fonts:
- asset: fonts/Comfortaa-Regular.ttf
- asset: fonts/Comfortaa-Medium.ttf
- asset: fonts/Comfortaa-Light.ttf
- asset: fonts/Comfortaa-Bold.ttf
weight: 900
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
💻 Solution Tried
Reinstalling flutter
Tried clearing the packages & getting them again
flutter clean
flutter pub get
Tried deleting pubspec.lock and running flutter pub get
Removing rm android/settings.gradle and running flutter create .
Tried removing C:/USERNAME/.gradle and C:/USERNAME/.gradle/caches both
Tried upgrading Android Studio
Tried upgrading flutter to flutter 2.2.3 the latest version!
Tried replacing settings.gradle code with the below one:
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
Any help would be appreciated, Thanks!
And please let me know if you need anything else for better understanding :)
If you're using outdated plugins and recently ran flutter upgrade, it's possible that cache of outdated packages is still kept and causing the issue. What you can try doing here is run flutter pub get and flutter pub upgrade if outdated versions were displayed on the logs. Running flutter pub outdated to upgrade the package versions should also work.
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
My flutter app runs fine on the emulator, runs fine on my android when connected via USB, but crashes before opening when updated from the play store. Does the same to everyone else that has tried the update. So I thought I would try rebuilding as apk and install from firebase distribution.
flutter build works fine if i run as appbundle, or apk but only fails on apk --split-per-abi.
I am not sure if this error has to do with why it's crashing or if it's a new problem.
Here is the error I get when running flutter build -v apk --split-per-abi
FAILURE: Build failed with an exception.
[ +1 ms] * Where:
[ ] Script
'/Users/me/development/flutter-3/packages/flutter_tools/gradle/flutter.gradle' line: 646
[ ] * What went wrong:
[ ] A problem occurred evaluating root project 'android'.
[ ] > A problem occurred configuring project ':app'.
[ +1 ms] > The value for this property cannot be changed any further.
[ ] * 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 1s
I seem to keep running into other issues related to this being caused by the gradle version or maybe google services version. I've tried several different versions. Currently using https://services.gradle.org/distributions/gradle-6.5-all.zip and
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.1.0'
I also checked the file in the error message, line 646 contains:
abiVersionCode * 1000 + variant.versionCode
I've run flutter clean and here is my flutter doctor -v output:
[✓] Flutter (Channel master, 1.24.0-4.0.pre.167, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)
• Flutter version 1.24.0-4.0.pre.167 at /Users/me/development/flutter-3
• Framework revision 22724370cb (54 minutes ago), 2020-10-30 11:00:24 -0700
• Engine revision 99cc50dfff
• Dart version 2.11.0 (build 2.11.0-266.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/me/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• 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-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.9.1
[✓] 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-6222593)
[✓] Android Studio (version 3.5)
• Android Studio at /Users/me/Library/Application
Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5900203/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_202-release-1483-b49-5587405)
[✓] VS Code (version 1.46.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.12.2
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.111
• No issues found!
Change the version of gradle on android/build.gradle file to 3.5.0.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
...
classpath 'com.android.tools.build:gradle:3.5.0' // Use this version
}
}
On android/gradle/wrapper/gradle-wrapper.properties, your distributionUrl should also have the following gradle version.
gradle-5.6.2-all.zip
so that you won't run into any other issues.
Finally, run these commands
rm -rf android/.gradle
rm -rf $HOME/.gradle # This is for Mac users
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
It should work like a charm! And update Gradle later on when things get little matured and stable.
android {
compileSdkVersion 30
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.test_flutter"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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.
}
}
}
Today (22.08.2020) after being prompted on Android Studio, i updated flutter. After that, whenever i do a pub get, i get the following error:
"Because every version of flutter from sdk depends on vector_math 2.1.0-nullsafety.2 which doesn't match any versions, flutter from sdk is forbidden.
So, because flutter_app3 depends on flutter any from sdk, version solving failed.
pub get failed (1; So, because flutter_app3 depends on flutter any from sdk, version solving failed.)"
see below flutter doctor -v result:
C:\Users\User\StudioProjects\flutter_app3>flutter doctor -v
[√] Flutter (Channel beta, 1.21.0-9.1.pre, on Microsoft Windows [Version 10.0.17134.1667], locale cs-CZ)
• Flutter version 1.21.0-9.1.pre at C:\src\flutter
• Framework revision be9bc8cb39 (4 days ago), 2020-08-18 09:46:08 -0700
• Engine revision 267070c17a
• Dart version 2.10.0 (build 2.10.0-7.2.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\User\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.47.2)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.12.2
[√] Connected device (1 available)
• HD1903 (mobile) • aa3eee24 • android-arm64 • Android 10 (API 29)
• No issues found!
pubspec.yaml:
name: flutter_app3
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Thanks in advance.
You used the channel beta flutter.
I think you need to use the stable channel.