簡體   English   中英

Flutter App 中的 AndroidManifest.xml 錯誤“未找到屬性 class”

[英]Error in AndroidManifest.xml in Flutter App "Attribute class not Found"

AndroidManifest.xml 在下面的代碼中顯示了 10 個錯誤。 我無法理解為什么會顯示這些錯誤以及如何解決這個問題。 幫助我擺脫這些錯誤。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.buis_talk">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

   <application
   android:requestLegacyExternalStorage="true"
        android:label="buis_talk"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:usesCleartextTraffic="true"
            
            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"
              />
            <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>

這些是錯誤

錯誤是:-

  1. android:requestLegacyExternalStorage="true" - "屬性 android:requestLegacyExternalStorage 在這里不允許"
  2. android:name="${applicationName}" - "Unresolvedclass:'{applicationName}'"
  3. android:icon="@mipmap/ic_launcher"> - "屬性 android: 此處不允許圖標"
  4. android:name=".MainActivity" - "未解決 class MainActivity"
  5. android:usesCleartextTraffic="true" - "屬性 android:usesCleartextTraffic 在這里不允許"
  6. android:launchMode="singleTop" - "屬性 android:launchMode 在這里不允許"
  7. android:theme="@style/LaunchTheme" - "屬性 android:theme is not allowed here"
  8. android:configChanges="....." - “屬性 android:此處不允許配置更改”
  9. android:hardwareAccelerated="true" - "屬性 android:hardwareAccelerated 在這里是不允許的"
  10. android:windowSoftInputMode="adjustResize"> - "屬性 android:windowSoftInputMode 在這里不允許"

TLDR

我想如果在Android Studio中單獨打開android文件夾,應該可以正常看到。 (也許,我不確定)。

長答案

Android 打開Flutter項目時, Studio無法理解Android內容。

如果是一個簡單的 Android 項目,那么它可以很容易地理解 Gradle 文件和你的 Java/Kotlin。

這對您作為 Flutter 開發人員意味着什么,當您編輯本機 Android 或 iOS 代碼時。 您將無法完成代碼。 Android Studio 將無法告訴您代碼中的錯誤。

Flutter 團隊正在努力解決這個問題。 這樣即使您打開了 Flutter 項目,您也可以擁有所有用於編輯本機代碼的酷 IntelliJ 功能。

另外,我想如果你單獨打開android,那你應該可以正常看到。 (也許,我不確定)。

  1. 如果項目在運行時失敗,則如附圖所示; 在第 29 行的末尾錯誤地添加了z

  2. 項目運行良好,但您擔心代碼是紅色的/錯誤的; 正如@powerman23rus詳細解釋的那樣,請忽略它。

  3. 此外,如果第 1 點和第 2 點不適用,那么您必須發布完整的錯誤日志,以便我們追蹤問題的根源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM