Ошибка при использовании плагина определения местоположения (Flutter) - PullRequest
0 голосов
/ 09 июля 2020

Я пытался создать приложение с Google-Maps и плагином местоположения, но получаю сообщение об ошибке.

Это ошибка, которую я получаю:

Plugin project :location_web not found. Please update settings.gradle.

Я искал в inte rnet и обнаружил, что я должен использовать этот код в файле 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 файл (в тех местах, где мой ключ я сделал ... чтобы никто не узнал ключ):

<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>

1 Ответ

1 голос
/ 09 июля 2020

Измените манифест на следующее:

<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.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...