flutter - 例外:无法构建插件analog_clock
问题描述
我正在尝试在仪表板屏幕上添加地图。
我的地图代码是这样的
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Maps Sample App'),
backgroundColor: Colors.green[700],
),
body: Stack(
children: <Widget>[
GoogleMap(initialCameraPosition: CameraPosition(target:
LatLng(-33.870840,151.206286),
zoom: 12)
)
],
)
),
);
我从这个链接得到它。
当我运行我的代码时,它给了我这个错误
插件项目:location_web 未找到。请更新 settings.gradle。
我通过使用此解决方案解决了它(使用 Peter Haddad 解决方案)
pubspec.yaml文件的依赖项是
dependencies:
intl: ^0.17.0
flutter:
sdk: flutter
analog_clock: ^0.0.1
get_it: ^6.1.1
url_launcher: ^5.4.11
shared_preferences: ^0.5.1+2
dio:
fluttertoast:
google_maps_flutter: ^0.5.30
location: ^3.0.2
我的 settings.gradle 文件代码是
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
在这里它显示错误,我也在其他屏幕上使用模拟时钟。
- - - 更新
这是 AndriodManifest.xml 文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.attendance_system_app">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="attendance_system_app"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDSBu24ZIgKe96hi27uK-cGugvpheAgaKQ"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
更新:
- - - 更新
这是我的清单文件,发生内核错误后
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.attendance_system_app">
<application
android:label="attendance_system_app"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
请帮助我如何解决它。
解决方案
问题不在于模拟时钟。它用于位置或 google_maps_flutter
您default_notification_channel_id
在清单中添加了。但这在资源中找不到。
更新: 对于那些无法找到“string.xml”的人,您可以在 android>app>src>main>res>values 下找到它。它与styles.xml 不同。如果您还没有,您可以创建一个:
- 右键单击“值”文件夹,
- 使用字符串名称创建新值资源,
- 并创建一个带有名称的字符串
fcm_default_channel
推荐阅读
- php - 读取并加入多个远程文件 PHP
- c++ - 我正在尝试用 C++ 编写一个排序算法进行练习,但它不起作用
- prolog - 寻求帮助理解简单的 Prolog 代码
- powershell - 如何使用 PowerShell 捕获 API 请求的输出值
- python - 在python中计算方差
- python - 列表Python中两个字典值的最大平均值
- php - 子文件夹中托管环境中的 .htaccess 和 Symfony 5
- mysql - 将一个表行与mysql中的另一个表列连接起来
- javascript - 以小时为单位的倒计时
- linux - 如何通过 /proc/x/mem 访问 64 位地址空间的上半部分?