gpt4 book ai didi

android - Flutter-Firebase构建失败 ':cloud_firestore:compileDebugJavaWithJavac'

转载 作者:行者123 更新时间:2023-12-03 04:23:29 29 4
gpt4 key购买 nike

我刚刚开始学习 flutter 和火力基础。我正在遵循本教程[https://grokonez.com/android/how-to-integrate-flutter-firebase-tutorial-app-android-studio],如前所述进行了所有操作,但应用程序未成功构建。这是我遇到的错误:

Launching lib\main.dart on Redmi 6 in debug mode...
Running Gradle task 'assembleDebug'...
Note: D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.2.5+1\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:9: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:248: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^
symbol: class NonNull
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:269: error: cannot find symbol
public Void apply(@NonNull Transaction transaction)
^
symbol: class NonNull
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:267: error: cannot find symbol
@Nullable
^
symbol: class Nullable
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:495: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^
symbol: class NonNull
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:548: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^
symbol: class NonNull
Note: D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.7.4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
> 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 58s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin cloud_firestore...
Running Gradle task 'assembleAarRelease'...
Finished with error: The plugin cloud_firestore could not be built due to the issue above.

应用程序/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 FileNotFoundException("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 plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.testflutter.flutterfirebase"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

android \ build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}

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

allprojects {
repositories {
google()
jcenter()


}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}

pubspec.yaml
name: flutterfirebase
description: A new Flutter application.

# 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.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
sdk: ">=2.1.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

cloud_firestore: ^0.7.4

dev_dependencies:
flutter_test:
sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/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:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/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.dev/custom-fonts/#from-packages

任何人都可以帮助解决此问题?已经搜寻了几个小时。提前致谢。

最佳答案

更新minSdkVersion:

minSdkVersion 16

进入:
minSdkVersion 23

关于android - Flutter-Firebase构建失败 ':cloud_firestore:compileDebugJavaWithJavac',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61185707/

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