构建发布版和调试版apk时,未找到Firebase Auth AndroidX依赖项。

3
请参见Flutter问题27982。我该如何解决?(注意:在firebase_auth错误消息中缩短的URL已被替换为完整链接)。
请参见底部的编辑。
编辑2:这是一个带有一些常用依赖项的预-AndroidX pubspec.yaml
据我了解,firebase_auth请求的依赖项(androidx.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://dev59.com/xek5XIcBkEYKwwoY7eME
    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

$ 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-beta\flutter
    • 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:\Users\Jackie\AppData\Local\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 Studio\jre\bin\java
    • 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 Files\Android\Android 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 Files\JetBrains\IntelliJ 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:\Users\Jackie\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.22.3

[√] VS Code, 64-bit edition (version 1.26.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.22.3

[√] Connected device (1 available)
    • SM N910T • c253d892 • android-arm • Android 6.0.1 (API 23)

编辑:

在安卓 build.gradle 中添加了 classpath 'com.google.android.gms:play-services-basement:16.2.0',但是得到了不同的错误信息。

在应用 build.gradle 中添加 implementation 'androidx.appcompat:appcompat:1.0.2' 没有起到帮助作用。

最初的回答:

C:\flutter_windows_v0.11.11-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.java:12: error: cannot find symbolimport androidx.appcompat.app.AppCompatActivity.content.Intent;
                                               ^
  symbol:   class content
  location: class AppCompatActivity
C:\flutter_windows_v0.11.11-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.java:27: error: incompatible types: Activity cannot be converted to AppCompatActivity
    channel.setMethodCallHandler(new FlutterSmsPlugin(registrar.activity()));
                                                                        ^
C:\flutter_windows_v0.11.11-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.java:92: error: cannot find symbol    intent.addCategory(Intent.CATEGORY_DEFAULT);
                       ^
  symbol:   variable Intent
  location: class FlutterSmsPlugin
C:\flutter_windows_v0.11.11-beta\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_sms-0.0.4+2\android\src\main\java\com\appleeducate\fluttersms\FlutterSmsPlugin.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
1个回答

0

目前,最初是针对Flutter提出的问题已经被关闭,并移至FlutterFire,因为这通常是Firebase插件的问题。

根据在GitHub上相关问题的更新,修复已经在更新版本的FlutterFire插件发布

嘿,
我们重新制作了 FlutterFire 插件,依赖于共享的“核心”(控制在 Android 上使用的 Firebase SDK 的版本),作为 FlutterFire 路线图的一部分,一周前发布了大量修复和新功能。
请尝试新版本并查看是否仍然存在此问题。此外,文档站点现在涵盖了 Android 安装,https://firebase.flutter.dev
如果仍然存在问题,请提交一个最新的 GitHub 问题。
有关迁移到新插件的帮助,请参阅新的迁移指南:https://firebase.flutter.dev/docs/migration

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接