android - Android Flutter 项目无法构建,出现各种错误
问题描述
我从 Github 获得源代码并下载了 zip 文件,然后用 Android Studio(Latest) 打开,然后我命令 Pub Get 下载依赖项。我想当我按下构建按钮时,它可能会像另一个颤动的安卓应用程序一样工作。
但这向我展示了很多错误,我尝试了 Stackoverflow 中的各种方法和 Google 中的解决方案,但所有解决方案都不起作用。
我使用的来源是https://github.com/nn1ks/RemoteFiles
源代码没问题,因为
我尝试了在线IDE,因为我认为问题来自IDE设置,但它也没有问题。似乎错误来自 Gradle 设置或版本。我怎么解决这个问题?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at
https://flutter.dev/go/android-project-migration
to migrate your project.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Launching lib\main.dart on SM N986N in debug mode...
Running Gradle task 'assembleDebug'...
lib/services/connection.g.dart:9:7: Error: The non-abstract class 'ConnectionAdapter' is missing implementations for these members:
- TypeAdapter.typeId
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class ConnectionAdapter extends TypeAdapter<Connection> {
^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/registry/type_adapter.dart:7:11: Context: 'TypeAdapter.typeId' is defined here.
int get typeId;
^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/provider-2.0.1+1/lib/src/provider.dart:179:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
? context.inheritFromWidgetOfExactType(type) as _Provider<T>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/provider-2.0.1+1/lib/src/provider.dart:180:19: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
: context.ancestorInheritedElementForWidgetOfExactType(type)?.widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/shared/custom_bottom_sheet.dart:291:30: Error: No named parameter with the name 'shadowThemeOnly'.
theme: Theme.of(context, shadowThemeOnly: true),
^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
static ThemeData of(BuildContext context) {
^^
lib/shared/custom_show_dialog.dart:269:36: Error: Method not found: 'ButtonTheme.bar'.
children.add(new ButtonTheme.bar(
^^^
lib/shared/custom_show_dialog.dart:635:30: Error: No named parameter with the name 'shadowThemeOnly'.
theme: Theme.of(context, shadowThemeOnly: true),
^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
static ThemeData of(BuildContext context) {
^^
lib/pages/home.dart:88:7: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
resizeToAvoidBottomPadding: true,
^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/material/scaffold.dart:1451:9: Context: Found this candidate, but the arguments don't match.
const Scaffold({
^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 7s
Exception: Gradle task assembleDebug failed with exit code 1
解决方案
尝试运行这个 -
- 颤振通道稳定
- 颤振升级
- 扑干净
删除此警告
Your Flutter application is created using an older version of the Android embedding
您可以将其添加到活动标记下的 AndroidManifest.xml 中。
<meta-data
android:name="flutterEmbedding"
android:value="2" />
这应该删除警告。
推荐阅读
- javascript - 如何使用反应更新d3强制布局中节点的数据
- python - 无法从 Python 中的 XML 文件中读取汉字
- flutter - 如何滚动扩展磁贴的列表视图构建器自动滚动到 Flutter 中的列表末尾?
- android - 在 Android API 22 中查看 FadeTo 不褪色
- android - 技术本地化
- json - 当 json 在 react native 中获取时变得未定义
- python - Python中二维凸包的周长
- python - 如何在 Django 过滤器的 kwargs 中传递用户名?
- php - 使用未定义的常量 IMAGETYPE_WEBP - 假定为 'IMAGETYPE_WEBP'
- php - 使用php删除字符之间的文件特定文件内容