我今天更新了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的事实有关。我将Google服务更新为最新版本(4.2.0),并根据IDE的提示升级到3.4.0
我在android / app / build.gradle中将已编译的SDKVersion从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文件中
我尝试通过'File> Invalidate Caches清除缓存并重新启动...'
我尝试过扑打干净和扑打医生-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
任何建议请解决,不胜感激!
答案 0 :(得分:0)
我认为您的问题出在androidX
[正如我在错误中所看到的],也是因为您正在使用firebase_auth: ^0.8.4+5
。
1。使用最新版本的android studio
希望这会有所帮助 检查一下:https://medium.com/@swhussain110/how-to-migrate-your-flutter-app-to-androidx-9a78eaaa924b