Firebase Auth Androidx依赖性在构建发布和调试APK时找不到



请参阅Flutter问题27982。如何解决此问题?(注意:firebase_auth中的缩短URL已用完整链接替换)。

请参阅底部的编辑。

编辑2:这是一个pre androidx pubspec.yaml,具有一些常见的依赖性。


就我的理解,firebase_authandroidx.legacy:legacy-support-v4:26.0.0)要求的依赖性不存在;我只能在Maven上找到v1.0.0

编辑:还会在flutter build apk --debug

上丢下类似的错误

复制步骤

1. Migrate to AndroidX
2. Include `firebase_auth` in `pubspec.yaml`
3. run `flutter build apk`

logs

$ flutter build apk
Initializing gradle...                                       0.5s
Resolving dependencies...                                   13.6s
Gradle task 'assembleRelease'...
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 firebase_auth will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://flutter.io/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.
         *********************************************************
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
   > Could not find androidx.legacy:legacy-support-v4:26.0.0.
     Required by:
         project :app
   > Could not find androidx.legacy:legacy-support-v4:26.0.0.
     Required by:
         project :app > project :firebase_auth > com.google.firebase:firebase-auth:16.0.5 > com.google.android.gms:play-services-basement:16.1.0
* 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 6s
Gradle task 'assembleRelease'... Done                        6.9s
Gradle task assembleRelease failed with exit code 1

PubSpec

name: timeswap_core
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.
# Read more about versioning at semver.org.
# 
# the number after '+' is the version code -- version name is before
version: 0.1.0+1
environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  cloud_firestore:
  firebase_auth:
  google_sign_in:
  dotenv:
  colorize:
  progress_hud:
  square_in_app_payments:
  uuid:
  flutter_slidable:
  flutter_sms:
  dynamic_theme:
  shared_preferences:
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_driver:
    sdk: flutter
  test: 1.5.1
  flutter_launcher_icons:
flutter_icons:
  android: true
  ios: true
  image_path: "assets/icon/icon.png"

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/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:
    - cfg/env.json
    - assets/   
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/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: 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,
  # see https://flutter.io/custom-fonts/#from-packages

android build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-auth:16.1.0'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.2, 0.99.99]'
        //classpath 'com.google.android.gms:play-services-basement:15.0.1'
    }
    subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
          && !details.requested.name.contains('multidex')) {
           details.useVersion "27.1.1"
        }
        // if (details.requested.group == 'androidx.legacy'  && details.requested.name.contains('legacy-support-v4')) {
        //     details.useVersion "1.0.0"
        // }
     }
  }
}
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}
rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序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"
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.timeswap.timeswapcore"
        minSdkVersion 21
        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 {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    // See https://stackoverflow.com/questions/50524672/build-fails-with-program-type-already-present-android-arch-core-util-function
    implementation 'androidx.arch.core:core-runtime:2.0.0-beta01'
    implementation 'androidx.arch.core:core-common:2.0.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

扑来医生

$ flutter doctor -v
[√] Flutter (Channel beta, v1.1.8, on Microsoft Windows [Version 10.0.17134.556], locale en-US)
    • Flutter version 1.1.8 at C:flutter_windows_v0.11.11-betaflutter
    • Framework revision 985ccb6d14 (5 weeks ago), 2019-01-08 13:45:55 -0800
    • Engine revision 7112b72cc2
    • Dart version 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:UsersJackieAppDataLocalAndroidsdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.
[√] Android Studio (version 3.3)
    • Android Studio at C:Program FilesAndroidAndroid Studio
    • Flutter plugin version 32.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[!] IntelliJ IDEA Ultimate Edition (version 2018.2)
    • IntelliJ at C:Program FilesJetBrainsIntelliJ IDEA 2018.2.4
    X Flutter plugin not installed; this adds Flutter specific functionality.
    • Dart plugin version 182.5124
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins
[√] VS Code (version 1.31.1)
    • VS Code at C:UsersJackieAppDataLocalProgramsMicrosoft VS Code
    • Flutter extension version 2.22.3
[√] VS Code, 64-bit edition (version 1.26.1)
    • VS Code at C:Program FilesMicrosoft VS Code
    • Flutter extension version 2.22.3
[√] Connected device (1 available)
    • SM N910T • c253d892 • android-arm • Android 6.0.1 (API 23)

编辑:

classpath 'com.google.android.gms:play-services-basement:16.2.0'添加到Android build.gradle并收到另一个错误消息。

implementation 'androidx.appcompat:appcompat:1.0.2'添加到应用程序build.gradle无济于事。

C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:12: error: cannot find symbolimport androidx.appcompat.app.AppCompatActivity.content.Intent;
                                               ^
  symbol:   class content
  location: class AppCompatActivity
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:27: error: incompatible types: Activity cannot be converted to AppCompatActivity
    channel.setMethodCallHandler(new FlutterSmsPlugin(registrar.activity()));
                                                                        ^
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:57: error: cannot find symbol    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
    ^
  symbol:   class Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:57: error: cannot find symbol    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                            ^
  symbol:   class Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:57: error: cannot find symbol    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                                   ^
  symbol:   variable Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:90: error: cannot find symbol    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
    ^
  symbol:   class Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:90: error: cannot find symbol    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                        ^
  symbol:   class Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:92: error: cannot find symbol    intent.addCategory(Intent.CATEGORY_DEFAULT);
                       ^
  symbol:   variable Intent
  location: class FlutterSmsPlugin
C:flutter_windows_v0.11.11-betaflutter.pub-cachehostedpub.dartlang.orgflutter_sms-0.0.4+2androidsrcmainjavacomappleeducatefluttersmsFlutterSmsPlugin.java:93: error: cannot find symbol    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    ^
  symbol:   variable Intent
  location: class FlutterSmsPlugin
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
9 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_sms:compileReleaseJavaWithJavac'.
         *********************************************************
WARNING: This version of firebase_auth will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See [url in error messages above] 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.
         *********************************************************
> 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 9s
Gradle task 'assembleRelease'... Done                       10.2s
Gradle task assembleRelease failed with exit code 1

当前,最初提出的颤音的问题已关闭并移至Flutterfire,因为这通常是Firebase插件的问题。

基于GitHub提交的相关问题的更新,修复程序已在FlutterFire插件的较新版本上发布。

嘿👋

我们对FlutterFire插件的返工以取决于共享的"核心"(控制Android上使用的Firebase SDK的版本)一周前出版了Flutterfire路线图的一部分吨的修复和新功能。

请您尝试新版本,看看这是否仍然是问题?此外,文档网站现在涵盖Android安装,https://firebase.flutter.dev

如果这仍然是一个问题,请提交新的最新github问题。

有关迁移到新插件的帮助,请参阅新的迁移指南:https://firebase.flutter.dev/docs/migration

最新更新