gpt4 book ai didi

android-studio - Flutter Android Studio 构建失败

转载 作者:IT老高 更新时间:2023-10-28 12:34:49 33 4
gpt4 key购买 nike

我的 Android studio flutter 项目开始出现找不到符号错误。

C:\Users\abc\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMe**ssagingPlugin.java:13: error: cannot find symbol
import androidx.annotation.NonNull;**
^
symbol: class NonNull
location: package androidx.annotation
C:\Users\abc\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:14: error: package androidx.localbroadcastmanager.content does not exist
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
^
C:\Users\abc\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0\android\src\main\java\io\flutter\plugins\firebasemessaging\FlutterFir**ebaseInstanceIDService.java:9: error: package androidx.localbroadcastmanager.content does not exist
import androidx.localbroadcastmanager.content.LocalBroadcastManager;**

任何人都知道出了什么问题?

根据其他用户的建议,我尝试重构为 AndroidX,但即使它是 compileSdkVersion 28 仍然出现错误。我还尝试使缓存无效并重新启动 android studio。

enter image description here

Gradle.properties gradle.properties

最佳答案

如果您使用的是 cloud_firestore: ^0.9.0 更改以下内容

pubspec.yaml

firebase_core: '^0.3.0' 添加到依赖项

android/build.gradle

mavenLocal() 添加到 buildscripts.repositories 和 allprojects.repositories

classpath 'com.google.gms:google-services:4.2.0' 添加到 buildscript.dependencies

android/grandle.properties

添加android.useAndroidX=trueandroid.enableJetifier=true

android/app/build.gradle

将 compileSdkVersion 更改为 28

将依赖项更改为

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

在底部添加 apply plugin: 'com.google.gms.google-services'

关于android-studio - Flutter Android Studio 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54375194/

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