【发布时间】:2021-10-19 10:50:40
【问题描述】:
我意识到我的 main/AndroidManifest.xml 文件中有错误。他们中的大多数报告:“属性 android:** 此处不允许”(** = 图标、launchMode、主题、configChanges、hardwareAccelerated、usesCleartextTraffic 和 windowSoftInputMode)。还有一个错误:“未解析的类'.MainActivity'(见附件截图)。
这并不妨碍构建和发布应用程序,但某些功能无法正常工作。
我尝试创建一个新的、干净的颤振项目(计数水龙头),但得到了同样的错误。我尝试在另一台计算机甚至不同的操作系统(Windows 和 Mac)上创建一个新的颤振项目,但问题仍然存在。并且我更新到了最新的 Android Studio (Arctic Fox 2020.3.1)。
Pub 以退出代码 0 结束。 Pub 升级已完成,退出代码为 0。 Pub 已过时,退出代码为 0。 Flutter Doctor -v 报告:
[✓] Flutter(Channel master,2.5.0-7.0.pre.105,Mac OS X 10.15.7 19H1323 darwin-x64,locale nb-NO) • Flutter 版本 2.5.0-7.0.pre.105,位于 /Users/christianottoruge/flutter • 上游仓库https://github.com/flutter/flutter.git • 框架修订 a2e33dec7c(8 小时前),2021-08-16 22:51:16 -0700 • 引擎修订版 7dc8eba6ae • Dart 版本 2.15.0(构建 2.15.0-15.0.dev)
[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 31.0.0) • Android SDK 位于 /Users/christianottoruge/Library/Android/sdk • 平台 android-30,构建工具 31.0.0 • Java 二进制文件位于:/Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java 版 OpenJDK 运行时环境(内部版本 11.0.10+0-b96-7281165) • 接受所有 Android 许可证。
[✓] Xcode - 为 iOS 和 macOS 开发 • Xcode 位于 /Applications/Xcode.app/Contents/Developer • Xcode 12.0.1,内部版本 12A7300 • CocoaPods 版本 1.10.1
[✓] Chrome - 为网络开发 • Chrome 位于 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio(版本 2020.3) • Android Studio 位于 /Applications/Android Studio.app/Contents • Flutter 插件可以从以下位置安装: ??? https://plugins.jetbrains.com/plugin/9212-flutter • Dart 插件可以从以下位置安装: ??? https://plugins.jetbrains.com/plugin/6351-dart • Java 版 OpenJDK 运行时环境(内部版本 11.0.10+0-b96-7281165)
[✓] 已连接设备(1 个可用) • Chrome(网络) • chrome • web-javascript • Google Chrome 92.0.4515.131
• 未发现任何问题!
我已经关闭并重新打开了 AndoidManifest 文件。 我已经尝试过文件-> 使缓存无效/重新启动。 我已将 File -> Project Structure -> Project Project SDK 设置为“Android API 29 平台”。 我已经构建、清理并重建了项目。
我的 AndroidManifest 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test_test_test.test_test_test">
<application
android:label="test_test_test"
android:icon="@mipmap/ic_launcher">
<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">
<!-- 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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<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>
<!-- 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>
错误消息如下所示:
没有MainActivity.xml文件,但是有一个MainActivity.kt文件放在app/src/main/kotlin/test_test_test/test_test_test/下。
代码是:
package com.test_test_test.test_test_test
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
谁能帮我解决这个问题?
问候,克里斯蒂安
【问题讨论】:
标签: android flutter android-studio android-activity android-manifest