gpt4 book ai didi

android-studio - 将 android studio 更新到版本 3.4 后 Gradle 失败

转载 作者:IT王子 更新时间:2023-10-29 06:57:18 24 4
gpt4 key购买 nike

我今天更新了 Android studio,我的 flutter 项目不再工作了。 Gradle 失败并显示以下消息:


* Error running Gradle:
ProcessException: Process "C:\Projects\firebase_setup_app\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: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
*********************************************************
WARNING: This version of firebase_auth will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility 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.
*********************************************************
Command: C:\Projects\firebase_setup_app\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.

我已经尝试在最新版本的 studio 中创建一个新的 flutter 项目并且构建正常。

问题似乎与我在我的项目中使用 google play 服务和 firebase 这一事实有关。我根据 IDE 的提示将谷歌服务更新到最新版本 (4.2.0) 并升级到 3.4.0

我在 android/app/build.gradle 中将 compiledSDKVersion 从 27 更新为 28

我已经将 android/gradle/gradle-wrapper.properties 中的 gradle 版本从 4.10.2 更新到 5.1.1,因为存在不兼容性,我被提示更新。

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

我已经完成重构>迁移到 AndroidX... 并包括:

android.useAndroidX=true
android.enableJetifier=true

在 gradle.properties 文件中

我已经尝试通过“文件>使缓存无效并重新启动...”来清除缓存

我试过 flutter clean 和 flutter doctor -v 没有显示任何问题:

C:\Projects\firebase_setup_app>flutter clean
Deleting 'build\'.
Deleting 'C:\Projects\firebase_setup_app\.dart_tool\'.

C:\Projects\firebase_setup_app>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 6.3.9600], locale en-GB)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] IntelliJ IDEA Community Edition (version 2018.3)
[√] Connected device (1 available)

• No issues found!

C:\Projects\firebase_setup_app>flutter doctor -v
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 6.3.9600], locale en-GB)
• Flutter version 1.2.1 at C:\src\flutter\flutter_windows_v1.0.0-stable\flutter
• Framework revision 8661d8aecd (10 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\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)
• All Android licenses accepted.

[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 34.0.2
• Dart plugin version 183.5901
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] IntelliJ IDEA Community Edition (version 2018.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.3
• Flutter plugin version 31.3.4
• Dart plugin version 183.5153.38

[√] Connected device (1 available)
• SM G930F • ce0616069dbace2f03 • android-arm64 • Android 8.0.0 (API 26)

• No issues found!

我还更新了 android/build.gradle 依赖项:

   dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
//classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}

android/app/build.gradle依赖如下:

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 'com.google.firebase:firebase-core:16.0.1'
}

apply plugin: 'com.google.gms.google-services'

我的 pubspec.yaml 包含以下插件:

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
google_sign_in: ^4.0.1+3
firebase_auth: ^0.8.4+5
firebase_core: ^0.3.4
#firebase_core: any
firebase_database: ^2.0.3

有任何建议请解决,不胜感激!

最佳答案

我认为您的问题出在 androidX[正如我在错误中看到的那样],而且您使用的是 firebase_auth: ^0.8.4+5 .

1.使用最新版本的android studio

  1. 在 android studio 中打开您的 flutter 项目,转到 Refactor,选择 Migrate to androidX。
  2. 当系统提示在新选项卡中打开窗口时[在新的 android studio 窗口中打开],这将在此窗口中打开您的 android 应用程序文件夹,再次选择迁移到 android X。该过程完成后,导航到底部并选择重构。再次为您的应用午餐

希望对你有帮助检查一下:https://medium.com/@swhussain110/how-to-migrate-your-flutter-app-to-androidx-9a78eaaa924b

关于android-studio - 将 android studio 更新到版本 3.4 后 Gradle 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55830256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com