Can't build release APK for flutter - firebase

I'm currently trying to build a signed release APK on Windows using Flutter. I've performed the tasks outlined in the documentation on the flutter site. When I run the build command here's the output I get. It seems to be around the firebase plugins. Any ideas?
pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_auth: 0.4.0
firebase_database: ^0.3.0
Flutter Doctor Output
C:\Users\myuser\projects\myflutterapp>flutter doctor
[√] Flutter (on Microsoft Windows [Version 10.0.16299.125], locale en-US, channel alpha)
• Flutter at C:\Users\myuser\flutter
• Framework revision 8f65fec5f5 (3 weeks ago), 2017-12-12 09:50:14 -0800
• Engine revision edaecdc8b8
• Tools Dart version 1.25.0-dev.11.0
• Engine Dart version 2.0.0-edge.d8ae797298c3a6cf8dc9f4558707bd2672224d3e
[√] Android toolchain - develop for Android devices (Android SDK 27.0.1)
• Android SDK at C:\Users\myuser\AppData\Local\Android\Sdk
• Android NDK at C:\Users\myuser\AppData\Local\Android\Sdk\ndk-bundle
• Platform android-27, build-tools 27.0.1
• ANDROID_HOME = C:\Users\myuser\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[√] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[-] Connected devices
• None
Error Log Information
C:\Users\myuser\projects\myflutterapp>flutter build apk --release
Initializing gradle... 0.9s
Resolving dependencies... 1.1s
Running 'gradlew assembleRelease'...
Configuration 'debugCompile' in project ':app' is deprecated. Use 'debugImplementation' instead.
Configuration 'profileCompile' in project ':app' is deprecated. Use 'profileImplementation' instead.
Configuration 'releaseCompile' in project ':app' is deprecated. Use 'releaseImplementation' instead.
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 'debugProvided' in project ':firebase_auth' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':firebase_auth' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'compile' in project ':firebase_core' is deprecated. Use 'implementation' instead.
Configuration 'debugProvided' in project ':firebase_core' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':firebase_core' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':firebase_database' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':firebase_database' is deprecated. Use 'releaseCompileOnly' instead.
Skipping AOT snapshot build. Fingerprint match.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:profileRuntimeClasspath'.
> Could not resolve project :firebase_auth.
Required by:
project :app
> Unable to find a matching configuration of project :firebase_auth:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
- Configuration 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :firebase_database.
Required by:
project :app
> Unable to find a matching configuration of project :firebase_database:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
- Configuration 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
> Could not resolve project :firebase_core.
Required by:
project :app
> Unable to find a matching configuration of project :firebase_core:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
- Configuration 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'profile' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
* 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 38s
Gradle build failed: 1

Turns out, the best way to handle this is to make the following change in android/app/build.gradle:
android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
// This is the main section that I've updated
// to get the release APK to build
buildTypes {
release {
profile {
matchingFallbacks = ['debug', 'release']
}
signingConfig signingConfigs.release
}
}
}
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'
With this change I was able to build the release APK.

try this:
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
android/app/build.gradle

I just deactivated the lint. It solved my release built issue.
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}

I had the same error, it turned out that I used buildTypes by mistake twice
buildTypes {
buildTypes {
.....
}
}

If you are having issue with build apk from android then try using terminal commands:
Flutter build apk --build-name =1.0.1
Flutter build apk --build-Number=10
Flutter build apk --build-name =1.0.1 --build-number=10
Make sure you will always change build name and build number when build apk. For example, if your last version name is 1.0.1 use 1.0.2 or higher and also with build number=11. Every time change this and your issue will be fixed.

I tried changing from debug to release. That solution didn't work for me. However, when I checked this site: https://www.dartlang.org/tools/pub/dependencies it says you can set a dependency without specifying a version. So in the pubspec.yaml file I did this and it worked for me...
dependencies:
flutter:
sdk: flutter
image_picker:
google_sign_in:
firebase_analytics:
firebase_auth:
firebase_database:
firebase_storage:

Related

react-native build failed after installing admob module

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1001 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Configure project :react-native-firebase_admob
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_admob:firebase.bom using default value: 26.3.0
:react-native-firebase_admob:ads.consent using default value: 1.0.6
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_admob:version set from package.json: 10.5.1 (10,5,1 - 10005001)
:react-native-firebase_admob:android.compileSdk using custom value: 29
:react-native-firebase_admob:android.targetSdk using custom value: 29
:react-native-firebase_admob:android.minSdk using custom value: 16
:react-native-firebase_admob:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 26.3.0
:react-native-firebase_app:play.play-services-auth using default value: 19.0.0
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 10.5.0 (10,5,0 - 10005000)
:react-native-firebase_app:android.compileSdk using custom value: 29
:react-native-firebase_app:android.targetSdk using custom value: 29
:react-native-firebase_app:android.minSdk using custom value: 16
:react-native-firebase_app:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Task :react-native-firebase_app:compileDebugJavaWithJavac
> Task :app:processDebugResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
37 actionable tasks: 29 executed, 8 up-to-date
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/muhamed-kveshkshaano/.gradle/caches/transforms-2/files-2.1/820765fbb4c63d086027395fb7f0dacc/play-services-ads-lite-19.6.0/AndroidManifest.xml:27:5-38:15: AAPT: error: unexpected element <queries> found in <manifest>.
* 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 32s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
here is the error, the main problem is each i install admob module #react-native-firebase/admob, it throws this error after trying a lot i couldnt find any solution, it only happens after installing admob module except that it build well, anyone knows whats wrong with that module
I was with the same problem and it work for me
in android/app/build.gradle
defaultConfig {
...
multiDexEnabled true // added for admob problem
}
...
dependencies {
...
implementation "androidx.multidex:multidex:2.0.1" // fix firebaseAdmob
}
in android/build.gradle
dependencies {
classpath('com.android.tools.build:gradle:4.1.2')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.3'
}
now open the android folder in Android Studio and wait for gradle will update
when finish the gradle update run npx react-native run-android
downgrade all the rnfirebase libraries that you are using to less than 10.0.0 (admob 7.6.11 and app 9.0.0), as I show in the image

Getting proguard error on adding androidx biometric API ( "androidx.biometric:biometric:1.0.1")

I am getting following error on building release apk after adding androidx biometric api "androidx.biometric:biometric:1.0.1" in gradle file
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
../release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
../release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
../release/values/values.xml:2853: error: resource android:attr/fontVariationSettings not found.
../release/values/values.xml:2854: error: resource android:attr/ttcIndex not found.
error: failed linking references.
I am using below mentioned sdk / tools version
buildToolsVersion = '28.0.3'
compileSdkVersion 28
targetSdkVersion 28
I am able to build debug apk and it works fine
I created my app following the instructions given here and here. And I have no problems creating and running a release APK. Here is the proguard section of my Gradle file
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Adding Firestore dependency causes error in Flutter app

Adding cloud_firestore: ^0.12.10 dependency in my flutter project gives errors.
These are the dependencies my project has:
dependencies:
url_launcher: ^5.0.0
flutter_launcher_icons: ^0.7.4
cloud_firestore: ^0.12.10
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
firebase_messaging: ^5.1.6
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/launcher_icon/LauncherIcon.png"
I tried to use different cloud_firestore versions, but none of them worked.
This is the output of flutter run command in the terminal:
Launching lib\main.dart on SM A505F in debug mode...
Initializing gradle... 1.1s
Resolving dependencies... 16.3s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[17.2.1,17.2.1]], but resolves to 16.5.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-iid is being requested by various other libraries at [[20.0.0,20.0.0]], but resolves to 17.1.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
* 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 11s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.8s
Gradle task assembleDebug failed with exit code 1
This is the output of flutter doctor -v:
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 10.0.18362.418], locale en-IN)
• Flutter version 1.9.1+hotfix.6 at D:\flutter_windows_v1.9.1+hotfix.2-stable\flutter
• Framework revision 68587a0916 (8 weeks ago), 2019-09-13 19:46:58 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\aditl\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• 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_202-release-1483-b03)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.40.0)
• VS Code at C:\Users\aditl\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.6.0
[√] Connected device (1 available)
• SM A505F • RZ8M60LFVPP • android-arm64 • Android 9 (API 28)
! Doctor found issues in 1 category.
from you log errors
* What went wrong:
Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[17.2.1,17.2.1]], but resolves to 16.5.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-iid is being requested by various other libraries at [[20.0.0,20.0.0]], but resolves to 17.1.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
you need to update firebase core to 17.2.1 if you have added it to your gradle files,
Although this is an issue with your project not being androidX enabled
see how to migrate to androidX
update
Cannot fit requested classes in a single dex file (# methods: 81876 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
you need to enable multidex for your application
as follows
android {
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation "androidx.multidex:multidex:2.0.0"
}
Add this line of code in your android/build.gradle file in the bottom. I think you missed the step of adding the services plugin.
Try this
and put cloud_firestore: ^0.12.10 dependency below firebase_messaging dependency.
Code:
apply plugin: 'com.google.gms.google-services'
Add this line inside your target 'Runner' do block in your Podfile, e.g.:
# ...
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.9.0'
# ...
end

Error Running Gradle - gradlew.bat exited abnormally (Error after adding firebase)

I am trying to read the firestore database. I have:
* Registered My app on firebase .
* copied googleservices.json in the app directory.
* copied the dependencies as firebase instructed.
Flutter Doctor
Upgrading Flutter from C:\flutter...
fa174a123..f31fc1bd0 master -> origin/master
* [new branch] revert-34243-flutter_frame_event -> origin/revert-34243-flutter_frame_event
Updating b593f5167..7a4c33425
11 files changed, 488 insertions(+), 83 deletions(-)
Upgrading engine...
Flutter 1.5.4-hotfix.2 • channel stable •
Framework • revision 7a4c33425d (6 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17763.557], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.35.1)
[√] Connected device (1 available)
! Doctor found issues in 1 category.
Error
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\USER\Desktop\crm\crm\crm\android\gradlew.bat" exited abnormally:
> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
*********************************************************
WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
See for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.0+4\android\build.gradle' line: 44
* What went wrong:
A problem occurred evaluating project ':firebase_core'.
> ..\..\pubspec.yaml (The system cannot find the file specified)
* 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
BUILD FAILED in 3s
Command: C:\Users\USER\Desktop\crm\crm\crm\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
PUBSPEC.YAML
name: flutter_charts_app
description: A new Flutter application.
# 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.
# Read more about versioning at semver.org.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.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_sparkline: ^0.1.0
flutter_staggered_grid_view: ^0.2.7
flutter_circular_chart: ^0.1.0
font_awesome_flutter: ^8.2.0
cloud_firestore: ^0.12.5
firebase_core: ^0.4.0+4
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page:
# 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
# For details regarding adding assets from package dependencies, see
# 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,
When I review my gradlew.bat file. The "JAVA_HOME goto findJavaFromJavaHome" is underlined in red. But I have both Java and Gradle added to my enviroment variables and path.
#if "%DEBUG%" == "" #echo off
#rem ##########################################################################
#rem
#rem Gradle startup script for Windows
#rem
#rem ##########################################################################
#rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
#rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
#rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
#rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%#eval[2+2]" == "4" goto 4NT_args
:win9xME_args
#rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
#rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
#rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
#rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
#rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
This issue is resolved in the 0.4.0+5 release of firebase_core. Please try updating and let us know if you run into any further issues.
Just upgrade gradle and kotlin version. In my case
ext.kotlin_version: '1.2.71' -> '1.3.50'
It started working fine.
If issue still persist then keep in mind that this issue is specific to android so setup android project in Android Studio. All issue will be shown. Fix them and it will start working.

Flutter: Build errors for cloud_firestore: above version "0.7.4"

I have been trying to resolve a build issue for hours until I realise it is due to Flutter plugin cloud_firestore. Version 0.7.4 builds fine for both Android and iOS but anything above 0.7.4 like 0.8.2+1 will have errors such as:
CloudFirestorePlugin.java:160: error: cannot find symbol
query = query.whereArrayContains(fieldName, value);
^ symbol: method whereArrayContains(String,Object) location: variable query of type
Query
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:598:
error: cannot find symbol
builder.setTimestampsInSnapshotsEnabled(
^ symbol: method setTimestampsInSnapshotsEnabled(Boolean) location: variable builder
of type Builder
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678:
error: cannot find symbol
return FieldValue.arrayUnion(toArray(readValue(buffer)));
^ symbol: method arrayUnion(Object[]) location: class FieldValue
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:680:
error: cannot find symbol
return FieldValue.arrayRemove(toArray(readValue(buffer)));
^ symbol: method arrayRemove(Object[]) location: class FieldValue Note:
/Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. 4 errors FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
* 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 11s Gradle task assembleDebug failed with exit code 1
I would like to use 0.8.2+1 cloud_firestore for both ios and Android because of the support of
await db.settings(timestampsInSnapshotsEnabled: true);
Appreciate some help here. Many Thanks!
There is a problem with google-services.json.
In my case, I was in the same situation while coding Firebase for Flutter on Google Codelabs. I put GoogleService-Info.plist in Xcode in the corresponding folder and put google-services.json in the corresponding folder in Adndroid Studio as well. iOS Simulator worked, but in Android Studio the window like the one below is displayed, then pressing the OK button and launching Android Emulator resulted in the corresponding error.
When coding from scratch and inserting the google-services.json file from the Finder instead of Android Studio, no error occurred.
It's not working because it is creating a gradle conflict. Version 0.7.3 of firestore is working because gradle tooling is updated at that version. Please refer changelog and also refer this answer for any other working versions of firebase products.
I feel you, I've also spent hours and hours trying to figure this out.
After building a SSCCE, and then applying the settings of that project to my project, and then some tweaking, I got my project working.
Although I adjusted more settings than I care to remember, these seem to have had the highest impact:
In pubspec.yaml:
# included two other common libraries others might use
cloud_firestore: 0.8.2+1
firebase_auth: 0.7.0
google_sign_in: 3.2.4
Explicitly disable these two features in android/gradle.properties :
android.useAndroidX=false
android.enableJetifier=false
Use these versions of dependencies in android/build.grade:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
And finally, use these settings in android/app/build.gradle:
android {
compileSdkVersion 27
...
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
...
}
...
}
...
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
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'
compile 'com.android.support:multidex:1.0.3'
}
It's also worth noting that I downloaded the google-services.json file again (though that didn't have any effect just by itself).
Any combination of these settings might help you.

Resources