Flutter stuck after linked it with firebase - android

after i connect flutter with firebase and get firebase packages the app run stuck at
Launching lib\main.dart on SM J600F in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
i have tried to delete the app and install it again i cleared the cash data also nothing happen, also i upgraded the futter to the last upgrade nothing happen
this is my pubspec.ymal file
name: finalp
description: A new Flutter project.
# 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.1.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.2
flutter_screenutil: ^0.4.2
firebase_auth:
firebase_core:
firebase_database:
firebase_crashlytics:
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
and this is the android build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
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
}
and this is the app build.gradle file
edef 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 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.finalp"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.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.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.google.gms.google-services'
and this the flutter doctor
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.17763.1098], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.4)
[√] IntelliJ IDEA Community Edition (version 2019.1)
[√] VS Code (version 1.43.2)
[√] Connected device (2 available)
! Doctor found issues in 1 category.
please help me :(

Upgrade:
minSdkVersion 16
into this:
minSdkVersion 21
By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn't really work with Jelly Bean (though, it's possible). Configuring Jelly Bean to work is beyond the scope of this codelab, so we'll change the minimum target SDK version from v16 to v21 (Lollipop, released 2014).
https://codelabs.developers.google.com/codelabs/flutter-firebase/#3

Related

How to solve Cannot invoke method afterEvaluate() on null object Flutter android, ios working well

I'm running an old flutter project using new flutter version.3.0.2, but when im debugging it shows an error like this. It run on ios
enter image description here
and i tried
Downgrading flutter version,
Updating dependancies/Reparing dependancies
Here is my app/build gradle
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 = '13'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0.12'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file('key.properties')
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.irings.elitco"
minSdkVersion 19
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['G:/AAIRINGSMAINAPPS/GITHUB/Elitco/key.jks'] ? file(keystoreProperties['G:/AAIRINGSMAINAPPS/GITHUB/Elitco/key.jks']) : null
storePassword keystoreProperties['storePassword']
}
}
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.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.firebase:firebase-messaging:20.1.0"
}
project-level build gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and pubspec.yaml
name: elitco
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.29+30
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
badges: ^1.1.0
http: ^0.12.0+1
fluttertoast: 3.1.3
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: 0.1.3
shared_preferences: 0.5.8
pin_entry_text_field: 0.1.3
flutter_plugin_pdf_viewer: 1.0.7
firebase_core: ^0.4.1+3
firebase_messaging: 6.0.9
cloud_firestore: 0.12.10
firebase_auth: 0.14.0+8
image_picker: ^0.6.7+12
google_maps_flutter: ^0.5.32
geolocator: 6.1.14
geocoder: 0.2.1
curved_navigation_bar: 0.3.4
carousel_pro: 0.0.13
carousel_slider: 2.3.1
pin_input_text_field: 3.1.1
imagebutton: 0.0.6
firebase_dynamic_links: ^0.5.0+11
share: ^0.6.3+1
solid_bottom_sheet: 0.1.9
smooth_star_rating: 1.1.1
connectivity: ^0.4.3+2
provider: 2.0.1
bubble: ^1.1.9+1
intl: 0.16.1
image_cropper: 1.3.1
screenshot: 0.1.1
esys_flutter_share: 1.0.2
delayed_display: 1.0.3
circular_check_box: 1.0.4
cached_network_image: 2.0.0
flutter_downloader: 1.4.4
path_provider: 1.6.10
permission_handler: 5.0.1
ext_storage: 1.0.3
numberpicker: 1.1.0
url_launcher: 5.7.10
country_code_picker: 1.7.0
dev_dependencies:
flutter_test:
sdk: flutter
sqflite: ^1.3.1
path: ^1.6.4
# 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/lght.png
- 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: opensans
fonts:
- asset: assets/fonts/OpenSans-Bold.ttf
- asset: assets/fonts/OpenSans-Light.ttf
- asset: assets/fonts/OpenSans-Regular.ttf
- asset: assets/fonts/OpenSans-SemiBold.ttf
- family: roboto
fonts:
- asset: assets/fonts/Roboto-Bold.ttf
- asset: assets/fonts/Roboto-Regular.ttf
- family: raleway
fonts:
- asset: assets/fonts/Raleway-Regular.ttf

Android App Crashing After Successfully Creating New User With Firebase In Flutter [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
My app crashes whenever I try to send create a new user with email and password with firebase_auth package. It successfully creates the account but then app crashes. I changed 'com.google.gms:google-services:4.2.0' to 3.2.1 in my build.gradle file but that did not helped. The problem still occurs and I don't know what to change.
The Error:
https://pastebin.ubuntu.com/p/fbzC3dNkv8/
My Code:
https://pastebin.ubuntu.com/p/5Ghjp2Hw55/
My Flutter Doctor Output
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 6.3.9600], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[!] VS Code (version 1.39.2)
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
My build.gradle file:
https://pastebin.ubuntu.com/p/t6MPZ5z34M/
My app level build.gradle file:
https://pastebin.ubuntu.com/p/tzztfQ4Nhb/
I solved the problem. I changed my gradle.properties file like this:
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536M
Also my app level gradle file 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 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.cagriserpin.focus_on"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
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
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
}
apply plugin: 'com.google.gms.google-services'
I hope that helps other people who encounters this problem

Adding firebase_messaging Plugin to flutter project on android stops app from launching with no error

I'm developing a flutter app with most of it done except for the push notification. When adding the firebase_messaging plugin in the pubspec.yaml and follow the setup process for android, the app stops launching with out giving any error. Just keeps on waiting to finish installation.
App migrated to android x from the start of development and other firebase plugins in use and working fine.Tested on different physical devices and emulator all with same issue. flutter clean run every time before build.
I'm sure there is something wrong with the setup or a conflict with another plugin but no error is being given.
pubspec.yaml
environment:
sdk: ">=2.2.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
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.2
http: ^0.12.0+1
#shared_preferences: ^0.5.1+1
rxdart: ^0.21.0
carousel_slider: ^1.1.0
google_maps_flutter: ^0.4.0
url_launcher: ^5.0.2
firebase_core: ^0.3.1+1
firebase_auth: ^0.8.3
firebase_dynamic_links: ^0.2.1
flutter_secure_storage: ^3.2.1+1
corsac_jwt: ^0.1.2
intl_translation: ^0.17.4
connectivity: ^0.4.3+1
flutter_svg: ^0.13.0+2
#flutter_statusbarcolor: ^0.1.0
google_sign_in: ^4.0.1+3
flutter_facebook_login: ^2.0.0
country_code_picker: ^1.1.5
webview_flutter: ^0.3.7+1
#permission_handler: '^3.1.0'
#notification_permissions: ^0.3.1
auto_size_text: ^1.1.2
launch_review: ^1.0.1
qr_flutter: ^2.0.0
geolocator: '^5.0.0'
flare_flutter: ^1.5.2
package_info: ^0.4.0+4
pin_code_text_field: ^1.3.6
meta: ^1.1.6
platform: ^2.2.0
firebase_messaging: ^5.1.0
dev_dependencies:
flutter_launcher_icons: 0.6.1
flutter_test:
sdk: flutter
/android/build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
// classpath 'com.google.gms:google-services:4.2.0'
}
}
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
}
/android/app/build.gradle
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 = '19'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '2.0.17'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "app.flutter.test"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
//// for relases
//release {
// signingConfig signingConfigs.release
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//}
//// for debugging
release{
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// implementation 'com.google.firebase:firebase-messaging:18.0.0'
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
terminal output
Launching lib/main.dart on ONE A2001 in debug mode...
Initializing gradle... 0.6s
Resolving dependencies... 3.5s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 20.2s
Built android\build\app\outputs\apk\debug\app-debug.apk.
Installing android\build\app\outputs\apk\app.apk... 28.7s
flutter doctor -v (the only issue of android license it never and it shouldn't effect)
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.17763.557], locale en-GB)
• Flutter version 1.7.8+hotfix.3 at C:\Users\ricardo\flutter
• Framework revision b712a172f9 (2 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\ricardo\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.35.1)
• VS Code at C:\Users\ricardo\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.2.0
[√] Connected device (1 available)
• ONE A2001 • 47fc4070 • android-arm64 • Android 6.0.1 (API 23)
! Doctor found issues in 1 category.
You try
run flutter doctor - android-licenses to make an android license. There is one problem there.
Lastest version firebase_messaging 5.1.0
Firebase Messaging Example this is an example of implementation if there is an error in your code
I hope this helps

flutter android - Failed to list versions for com.google.android.gms:play-services-location

Got this err when compiling android, the used to be compiling ok but I have no idea what went wrong.
Ios compiles and works fine tho. I tried a few things including check gradle file has google() and the correct version etc but nothing helps.
*********************************************************
FAILURE: Build failed with an exception.
WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
See goo.gl/CP92wY for more information on the problem and how to fix it.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
> Could not resolve com.google.android.gms:play-services-location:15.+.
*********************************************************
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Could not list versions using M2 pattern 'https://raw.github.com/g123k/ShortcutBadger/master/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://raw.github.com/g123k/ShortcutBadger/master/com/google/android/gms/play-services-location/'.
> Could not GET 'https://raw.github.com/g123k/ShortcutBadger/master/com/google/android/gms/play-services-location/'. Received status code 400 from server: Bad Request
* 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 23s
Finished with error: Gradle task assembleDebug failed with exit code 1
root build.gradle
buildscript {
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1' // it was 3.3.1 before but didnt compile, 3.2.1 compiles but with firebase errors
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build.gradle
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.berkey.berkey"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
// implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
// implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//
// android.useAndroidX=true
// android.enableJetifier=true
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
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.release
}
}
}
flutter {
source '../..'
}
dependencies {
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
Pubspec.yaml
description: A new Flutter project.
version: 1.2.0+3
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
algolia: ^0.1.3+2
firebase_auth: ^0.8.0+3
cupertino_icons: ^0.1.2
google_sign_in: ^4.0.1
cloud_firestore: ^0.9.0+1
firebase_storage: ^2.0.1
image_picker: ^0.5.0+3
location: ^2.0.0
firebase_messaging: ^3.0.1
geolocator: ^3.0.0
firebase_core: ^0.3.0+1
flutter_launcher_icons: "^0.7.0"
flutter_linkify: 1.0.3
url_launcher: ^5.0.1
permission_handler: '^2.2.0'
flutter_app_badger: ^1.0.2
flutter doctor
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
✗ Verify that all connected devices have been paired with this computer in Xcode.
If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
To update with Brew, run:
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)
Sometimes it's due to an issue with the internet connection. Try to check if you have a proper connection.

Flutter google_sign_in error : Unable to merge dex

Dear Flutter community,
I am banging my head on a seemingly simple task.
I want to add firebase authentication to my app. It worked on iOS but as I tried to implement it for android, I systematically get the error :
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... Resolving dependencies... Running 'gradlew
assembleDebug'... Configuration 'compile' in project ':app' is
deprecated. Use 'implementation' instead. registerResGeneratingTask is
deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use
registerGeneratedFolders(FileCollection) registerResGeneratingTask is
deprecated, use registerGeneratedFolders(FileCollection) Configuration
'compile' in project ':google_sign_in' is deprecated. Use
'implementation' instead.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge
dex
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 34s Finished with error: Gradle build failed: 1
I reproduced the error using 'flutter create' then adding Firebase capabilities following the codelab
https://codelabs.developers.google.com/codelabs/flutter-firebase/#4
Here is the only modification to pubspec.yaml
dependencies:
flutter:
sdk: flutter
google_sign_in: 0.3.1 # ONLY MODIFICATION
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
general build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0' #ONLY MODIF
}
}
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
}
App build.gradle :
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
}
}
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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mycompany.test"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
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.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
here is the flutter doctor output :
[✓] Flutter (on Mac OS X 10.13.2 17C88, locale fr-BE, channel master)
• Flutter at /Users/sergebesnard/flutter
• Framework revision 4d2c2aaaa1 (6 days ago), 2017-12-27 07:30:31 -0800
• Engine revision 7c126001d8
• Tools Dart version 1.25.0-dev.11.0
• Engine Dart version 2.0.0-edge.9e8a3e2d31621c1bdf6139d068e7898a2ac2ab5a
[✓] Android toolchain - develop for Android devices (Android SDK
27.0.2)
• Android SDK at /Users/sergebesnard/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.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_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.3.1
[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] IntelliJ IDEA Community Edition (version 2017.2.5)
• Flutter plugin version 18.0
• Dart plugin version 172.4155.35
[✓] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)
I am obviously new to Android development, and would prefer not to have to become expert to get the tutorial working. Every solution I found required tinkering with the .gradle files and only apply to react-native.
Thank you for your help !
I also had the same issue and I read that you had to include multiDexEnabled true in the app\build.gradle defaultConfig section. This worked for me.
This error means that some of your dependencies use a different version of the google play services.
You'd have to downgrade/upgrade plugins to unify the version used
Change minSdkVersion in android/app/build.gradle from 16 to 21
Final Versions
pubspec.yaml
cloud_firestore: ^0.8.2+3
android/build.gradle
classpath 'com.google.gms:google-services:3.2.1' // Google Services plugin
android/app/build.gradle
targetSdkVersion 27
minSdkVersion 21
Solved : incompatible versions used between plugin and framework.
Google SignIn plugin 0.4.0 and above should be used with new projects created with flutter create in its latest version.
The codelab is no longer valid and should be updated.
This link solved the same issue for me.
First I set dependencies in my pubspec.yaml to
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.8.2
and ran flutter packages get in my IDE's terminal.
Also I had to change the minimum target SDK version:
Open android/app/build.gradle, then find the line that says
minSdkVersion 16.
Change that line to minSdkVersion 21.
Save the file.
This alone may fix your problem; however I had to also do the following because some of my dependency versions were mismatched.
I had to open android/app/build.gradle, then add the following line as the last line in the file:
apply plugin: 'com.google.gms.google-services'
Next, I had to open android/build.gradle, then inside the buildscript tag, add a new dependency:
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1' // new
}
}
After this my app finally ran on the android emulator.
The link has a more complete walkthrough if you get stuck.
Also, to note, I did not have to set multiDexEnabled to true.
The problem here may be that the plugins you are depending on have conflicting gradle dependencies.
This SO answer here https://stackoverflow.com/a/49901209/90918 provides a description of how to solve this problem by finding the conflicting dependencies and overriding them.
Quoting the original answer:
Your two packages seem to disagree on their transitive dependencies.
One wants 11.6.+, the other wants 11.+ of some play-services
dependencies. Since both 11.6.2 and 11.8.0 are out there, this is
going to end up with a conflict.
If you run ./gradlew androidDependencies in your android/ folder,
you get a listing of the result of dependency resolution, containing,
among others, the following:
+--- :flutter_google_place_picker (variant: release)
+--- com.google.android.gms:play-services-location:11.8.0#aar
+--- com.google.android.gms:play-services-places:11.6.2#aar
+--- com.google.android.gms:play-services-maps:11.6.2#aar
+--- com.google.android.gms:play-services-base:11.8.0#aar
+--- com.google.android.gms:play-services-tasks:11.8.0#aar
+--- com.google.android.gms:play-services-basement:11.8.0#aar
These 11.6.2 and 11.8.0 packages are not going to work together. To
resolve this, you need to patch your dependencies to be consistent
with each other, or add a dependency override to the top level of your
android/app/build.gradle file and hope for the best:
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-places:11.8.0'
force 'com.google.android.gms:play-services-location:11.8.0'
}
}
I had the same problem
I ve added on my App/build.gradle on android/defaultConfig the line :
multiDexEnabled true
and on dependencies
implementation 'androidx.multidex:multidex:2.0.1'
App/build.gradle look like this:
def localProperties = new Properties()
...
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
....
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
.....
implementation 'androidx.multidex:multidex:2.0.1'
}
it works for me
The reason is you are using the different version of dependencies. To fix this go to your project/App/src/ and open Build.gradle. Then Add multiDexEnabled true Line inside the default config section.
Ex:Like this
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
I had added admob_flutter: ^0.3.4 in my flutter app but didn't used anywhere. Removing from pubspec.yaml file works for me.

Categories

Resources