插件项目:location_web 未找到。请更新 settings.gradle。我该如何解决?
Plugin project :location_web not found. Please update settings.gradle. How do I fix this?
我在我的 android flutter 应用程序中使用了 google 地图 api 和 location pub,dev 包,并尝试使用 url 调出图像来自 api。
这是带有一些代码的 url:
class LocationHelper{
static String mapviewpointer({double latitude, double longitude}){
return "https://maps.googleapis.com/maps/api/staticmap?center=$latitude,$longitude&zoom=13&size=600x300&maptype=roadmap&markers=color:pink%7Clabel:C%7C$latitude,$longitude&key=$GOOGLE_API_KEY";
}
}
它抛出以下错误消息:
Plugin project :location_web not found. Please update settings.gradle;
我不知道如何解决这个错误。
这是我在终端中收到的另一个错误:
I/flutter (21880): Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3CString%3E'
我收到上述错误消息的区域在我的代码中:
Future <String> _getUserLocation() async{
final locData = await Location().getLocation();
final staticMapUrl = LocationHelper.mapviewpointer(
latitude: locData.latitude,
longitude: locData.longitude,
);
return staticMapUrl;
}
final mapview = _getUserLocation();
class NearbyScreen extends StatelessWidget {
@override
//LocationHelper.mapviewpointer(latitude: )
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Container(height:170, width: double.infinity,
child:Image.network(mapview.toString())
),
Text("hello"),
],
);
}
}
这是否与我在 _getUserlocation
函数中返回 Future<String>
而不是 string
这一事实有关?我该如何解决这个问题?
使用以下 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
}
这将创建一个 .flutter-plugin
文件,其中包含插件及其路径。
我遇到了同样的问题,按照@Peter Haddad 的回答,我复制并替换了 settings.gradle 中的代码(全部),我在解析属性和文件的符号时遇到了错误。
修复它:转到工具 -> Flutter -> 在 Android Studio
中打开以进行编辑
在 Android Studio window 中转到文件 -> 使缓存无效并重新启动
这似乎为我解决了这个问题。
添加到你的 flutter 应用中 -> android -> settings.gradle
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
}
如所见here
有关该问题的更多信息here
删除 ProjectName/Build 文件夹,它已解决我的问题。
修复了安装了 facebook flipper 的用户
我本来可以将其添加为评论,但让我post将其作为具有正确代码格式的答案。
如果您安装了 facebook 的 flipper,并带有相关的 flutter_flipperkit 插件,那么您的 settings.gradle
应该已经修改了。
要使用@Peter Haddad 和@Paulo Belo 建议的修复,您需要保持 flipper 的插件加载并添加其他条件:
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
if (name == 'flutter_flipperkit') {
// flipper loading
include ':flipper-no-op'
project(':flipper-no-op').projectDir = new File(pluginDirectory, 'flipper-no-op')
}
else {
// location_web not found fix
include ":$name"
project(":$name").projectDir = pluginDirectory
}
}
希望这对某人有所帮助。
我在我的 android flutter 应用程序中使用了 google 地图 api 和 location pub,dev 包,并尝试使用 url 调出图像来自 api。 这是带有一些代码的 url:
class LocationHelper{
static String mapviewpointer({double latitude, double longitude}){
return "https://maps.googleapis.com/maps/api/staticmap?center=$latitude,$longitude&zoom=13&size=600x300&maptype=roadmap&markers=color:pink%7Clabel:C%7C$latitude,$longitude&key=$GOOGLE_API_KEY";
}
}
它抛出以下错误消息:
Plugin project :location_web not found. Please update settings.gradle;
我不知道如何解决这个错误。
这是我在终端中收到的另一个错误:
I/flutter (21880): Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3CString%3E'
我收到上述错误消息的区域在我的代码中:
Future <String> _getUserLocation() async{
final locData = await Location().getLocation();
final staticMapUrl = LocationHelper.mapviewpointer(
latitude: locData.latitude,
longitude: locData.longitude,
);
return staticMapUrl;
}
final mapview = _getUserLocation();
class NearbyScreen extends StatelessWidget {
@override
//LocationHelper.mapviewpointer(latitude: )
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Container(height:170, width: double.infinity,
child:Image.network(mapview.toString())
),
Text("hello"),
],
);
}
}
这是否与我在 _getUserlocation
函数中返回 Future<String>
而不是 string
这一事实有关?我该如何解决这个问题?
使用以下 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
}
这将创建一个 .flutter-plugin
文件,其中包含插件及其路径。
我遇到了同样的问题,按照@Peter Haddad 的回答,我复制并替换了 settings.gradle 中的代码(全部),我在解析属性和文件的符号时遇到了错误。
修复它:转到工具 -> Flutter -> 在 Android Studio
中打开以进行编辑在 Android Studio window 中转到文件 -> 使缓存无效并重新启动
这似乎为我解决了这个问题。
添加到你的 flutter 应用中 -> android -> settings.gradle
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
}
如所见here
有关该问题的更多信息here
删除 ProjectName/Build 文件夹,它已解决我的问题。
修复了安装了 facebook flipper 的用户
我本来可以将其添加为评论,但让我post将其作为具有正确代码格式的答案。
如果您安装了 facebook 的 flipper,并带有相关的 flutter_flipperkit 插件,那么您的 settings.gradle
应该已经修改了。
要使用@Peter Haddad 和@Paulo Belo 建议的修复,您需要保持 flipper 的插件加载并添加其他条件:
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
if (name == 'flutter_flipperkit') {
// flipper loading
include ':flipper-no-op'
project(':flipper-no-op').projectDir = new File(pluginDirectory, 'flipper-no-op')
}
else {
// location_web not found fix
include ":$name"
project(":$name").projectDir = pluginDirectory
}
}
希望这对某人有所帮助。