android - 使用定位插件(Flutter)时出错

标签 android flutter dart location

我尝试使用 Google-Maps 和位置插件构建应用程序,但出现错误。
这是我得到的错误:

Plugin project :location_web not found. Please update settings.gradle.
我在互联网上搜索,发现我应该在 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
}
但是当我这样做时,我收到以下错误:
FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:processDebugResources'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
       > Android resource linking failed
         D:\App Entwickeln\Projekte\Google-Maps\gmaps_test\android\Entwickeln\Projekte\Google-Maps\gmaps_test\android\app\src\main\AndroidManifest.xml:15:9-83: AAPT: error: unexpected element <uses-permission> found in <manifest><application>.
    
    
    * 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
以下是我的androidmanifest.xml flile (在我制作 key 的地方......所以没有人认出 key ):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gmaps_test">

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="gmaps_test"
        android:icon="@mipmap/ic_launcher">

        <meta-data android:name="..."
            android:value="..."/>
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <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">

            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <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>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

最佳答案

将 list 更改为以下内容:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gmaps_test">
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="gmaps_test"
        android:icon="@mipmap/ic_launcher">

        <meta-data android:name="..."
            android:value="..."/>
将其添加到 manifest 下直接标记。

关于android - 使用定位插件(Flutter)时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62812052/

相关文章:

Android 的 RelativeLayout 似乎坏了

Android Intent 过滤器不从浏览器启动应用程序

在应用栏上更新时,Flutter 脚手架更新了整个页面

firebase - 错误 : No named parameter with the name 'merge'

dart - 测试文本小部件中的子字符串

android - 同一个包中的两个 Activity 是否属于同一个线程?

android - 从 tablayout 中的每个选项卡获取 EditText 的值

flutter - 创建字符串翻译(.arb 文件)时如何修复错误 : The getter 'elements2' isn 't defined for the class ' ListLiteral'.

flutter - Flutter SingleChildScrollView将不会滚动

dictionary - 有没有办法在map/forEach中标识当前索引