简体   繁体   English

Flutter App 中的 AndroidManifest.xml 错误“未找到属性 class”

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

AndroidManifest.xml showing me 10 errors in the code below. AndroidManifest.xml 在下面的代码中显示了 10 个错误。 I am unable to understand why it is showing these errors and how can I resolve this.我无法理解为什么会显示这些错误以及如何解决这个问题。 Help me out from these errors.帮助我摆脱这些错误。

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

这些是错误

Errors are:-错误是:-

  1. android:requestLegacyExternalStorage="true" - "Attribute android:requestLegacyExternalStorage is not allowed here" android:requestLegacyExternalStorage="true" - "属性 android:requestLegacyExternalStorage 在这里不允许"
  2. android:name="${applicationName}" - "Unresolvedclass:'{applicationName}'" android:name="${applicationName}" - "Unresolvedclass:'{applicationName}'"
  3. android:icon="@mipmap/ic_launcher"> - "Attribute android:icon is not allowed here" android:icon="@mipmap/ic_launcher"> - "属性 android: 此处不允许图标"
  4. android:name=".MainActivity" - "Unresolved class MainActivity" android:name=".MainActivity" - "未解决 class MainActivity"
  5. android:usesCleartextTraffic="true" - "Attribute android:usesCleartextTraffic is not allowed here" android:usesCleartextTraffic="true" - "属性 android:usesCleartextTraffic 在这里不允许"
  6. android:launchMode="singleTop" - "Attribute android:launchMode is not allowed here" android:launchMode="singleTop" - "属性 android:launchMode 在这里不允许"
  7. android:theme="@style/LaunchTheme" - "Attribute android:theme is not allowed here" android:theme="@style/LaunchTheme" - "属性 android:theme is not allowed here"
  8. android:configChanges="....." - "Attribute android:configChanges is not allowed here" android:configChanges="....." - “属性 android:此处不允许配置更改”
  9. android:hardwareAccelerated="true" - "Attribute android:hardwareAccelerated is not allowed here" android:hardwareAccelerated="true" - "属性 android:hardwareAccelerated 在这里是不允许的"
  10. android:windowSoftInputMode="adjustResize"> - "Attribute android:windowSoftInputMode is not allowed here" android:windowSoftInputMode="adjustResize"> - "属性 android:windowSoftInputMode 在这里不允许"

TLDR TLDR

I think if you open the android folder separately in Android Studio , then you should be able to see properly.我想如果在Android Studio中单独打开android文件夹,应该可以正常看到。 (Maybe, I'm not sure). (也许,我不确定)。

Long answer长答案

Android Studio can't understand the Android content when a Flutter project is opened. Android 打开Flutter项目时, Studio无法理解Android内容。

If it's a simple Android project, then it can easily understand the Gradle files and your Java/Kotlin.如果是一个简单的 Android 项目,那么它可以很容易地理解 Gradle 文件和你的 Java/Kotlin。

What this means for you as a Flutter developer is that, when you are editing native Android or iOS code.这对您作为 Flutter 开发人员意味着什么,当您编辑本机 Android 或 iOS 代码时。 You will not get code completion.您将无法完成代码。 Android Studio will not be able to tell you about the errors in your code. Android Studio 将无法告诉您代码中的错误。

The Flutter team is working on this. Flutter 团队正在努力解决这个问题。 So that you can have all the cool IntelliJ features for editing Native code EVEN when you have a Flutter project is opened.这样即使您打开了 Flutter 项目,您也可以拥有所有用于编辑本机代码的酷 IntelliJ 功能。

Also, I think if you open the android separately, then you should be able to see properly.另外,我想如果你单独打开android,那你应该可以正常看到。 (Maybe, I'm not sure). (也许,我不确定)。

  1. If project is getting failed when you run it then as it is showing in attached image;如果项目在运行时失败,则如附图所示; at the end of line no 29 that a z is added mistakenly.在第 29 行的末尾错误地添加了z

  2. And project is running fine but you are worried about code being red/wrong;项目运行良好,但您担心代码是红色的/错误的; just ignore it as @powerman23rus explained it in detail.正如@powerman23rus详细解释的那样,请忽略它。

  3. Also if point 1 & 2 is not applicable then you have to post full error logs for us to trace the issue origins.此外,如果第 1 点和第 2 点不适用,那么您必须发布完整的错误日志,以便我们追踪问题的根源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM