firebase - 运行 Gradle 时出错 - gradlew.bat 异常退出(添加 firebase 后出错)

标签 firebase android-studio gradle flutter google-cloud-firestore

我正在尝试读取 firestore 数据库。我有: * 在 firebase 上注册了我的应用程序。 * 在 app 目录中复制 googleservices.json。 * 按照 firebase 的指示复制依赖项。

flutter 医生

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.

错误

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,

当我查看我的 gradlew.bat 文件时。 “JAVA_HOME goto findJavaFromJavaHome”带有红色下划线。但是我将 Java 和 Gradle 添加到我的环境变量和路径中。

@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

最佳答案

此问题已在 0.4.0+5 中解决发布 firebase_core。请尝试更新,如果您遇到任何其他问题,请告诉我们。

关于firebase - 运行 Gradle 时出错 - gradlew.bat 异常退出(添加 firebase 后出错),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56582217/

相关文章:

android - 如何在下层库中初始化Firebase Cloud Messaging?

java - Android 资源链接失败值,styles.xml

android - 获取 `Error:Cannot get property ' :lib' on null object` on a new Android Studio project

java - CountDownTimer cancel() 不会取消计时器并继续工作

javascript - 如何使用 Cloud Functions for Firebase 检测浏览器类型?

ios - 推送通知是否需要 Firebase 中每个 iOS 应用的常规设置中的所有字段?

android - 库升级后的Dex合并问题

java - view.getId() 不等于 R.id.myBtn

java - Android 找不到类 'android.app.job.JobScheduler'

android - 使用 Gradle 设置单元测试时出错