构建发布和调试 apk 时未找到 Firebase Auth AndroidX 依赖项
Posted
技术标签:
【中文标题】构建发布和调试 apk 时未找到 Firebase Auth AndroidX 依赖项【英文标题】:Firebase Auth AndroidX Dependency not found while building release and debug apk 【发布时间】:2019-07-11 07:19:50 【问题描述】:见flutter issue 27982。我该如何解决这个问题? (注:firebase_auth
错误信息中的短网址已替换为完整链接)。
请参阅底部的编辑。
编辑 2:这是一个 pre-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`
日志
$ 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
发布规范
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
应用构建.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://***.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-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)
编辑:
将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-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】:目前,originally filed for Flutter 的问题已关闭并移至FlutterFire,因为这通常是 Firebase 插件的问题。
基于related issue filed in GitHub 的更新,在较新版本的 FlutterFire 插件上修复了have been released。
嘿?
我们对 FlutterFire 插件的返工以依赖于一个共享的“核心” (控制 Android 上使用的 Firebase SDK 的版本)为 FlutterFire 路线图的一部分是在一周前发布的 大量的修复和新功能。
请你试试新版本,看看这是否仍然是一个 问题?此外,文档站点现在涵盖了 Android 安装,https://firebase.flutter.dev
如果这仍然是一个问题,那么请提交一个最新的 GitHub 问题。
有关迁移到新插件的帮助,请参阅新迁移 导游:https://firebase.flutter.dev/docs/migration
【讨论】:
以上是关于构建发布和调试 apk 时未找到 Firebase Auth AndroidX 依赖项的主要内容,如果未能解决你的问题,请参考以下文章
没有找到类“com.google.firebase.provider.FirebaseInitProvider,在使用工作室构建从 Eclipse 升级 apk 时
iOS XCode - 为 Profile 构建时未找到 Swift 类