更新插件和android studio之后。每次在android studio中重新启动后,我都必须手动配置dart-sdk。当我升级dart-sdk时显示此错误=>
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+4\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.4\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:137: warning: [unchecked] unchecked cast
return (List<String>) stream.readObject();
^
required: List<String>
found: Object
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.4\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:182: warning: [unchecked] unchecked method invoca
tion: constructor <init> in class ArrayList is applied to given types
List<String> listValue = new ArrayList<>((Set) value);
^
required: Collection<? extends E>
found: Set
where E is a type-variable:
E extends Object declared in class ArrayList
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.4\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:182: warning: [unchecked] unchecked conversion
List<String> listValue = new ArrayList<>((Set) value);
^
required: Collection<? extends E>
found: Set
where E is a type-variable:
E extends Object declared in class ArrayList
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.4\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:182: warning: [unchecked] unchecked conversion
List<String> listValue = new ArrayList<>((Set) value);
^
required: List<String>
found: ArrayList
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.4\android\src\main\java\io\flutter\plugins\sharedpreferences\SharedPreferencesPlugin.java:26: warning: [deprecation] getFlutterEngine() i
n FlutterPluginBinding has been deprecated
setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
^
5 warnings
也没有在代码中显示建议。我花了整整一天的时间来解决此错误,请帮忙。在此之后,我再也不会更新任何插件或我的android studio了。
答案 0 :(得分:1)
只需在您的build.gradle文件中添加multiDexEnabled true
defaultConfig {
applicationId "com.test.testapp"
minSdkVersion 19
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// add this line
multiDexEnabled true
}
在同一文件中,添加multidex依赖项
dependencies {
// If you're project has androidx support then add this dependency
implementation 'androidx.multidex:multidex:2.0.1'
// If you're project doesn't have androidx support then add this dependency
implementation 'com.android.support:multidex:1.0.3'
}
要详细了解androidX迁移visit the documentation here
答案 1 :(得分:0)
尝试运行flutter clean
和flutter packages get
命令。在Android Studio内部,使缓存无效并重新启动(文件->使缓存无效/重新启动)。
答案 2 :(得分:0)
迁移到Android X 并将gradle文件中的每个Android库覆盖为AndroidX 应该可以。