我意识到我的主/AndroidManifest.xml文件中存在错误。其中大部分报告:“此处不允许使用属性android:**”(** = icon,launchMode,theme,configChanges,hardwareAccelerated,usesCleartextTraffic和windowSoftInputMode)。还有一个错误:“未解析的类'.MainActivity'(请参见附加的截图)。
这不会妨碍构建和发布应用程序,但某些功能无法正常工作。
我尝试创建一个新的干净的flutter项目(计算点击次数),但仍然出现相同的错误。我尝试在不同的计算机上甚至在不同的操作系统上(Windows和Mac)创建一个新的flutter项目,但问题仍然存在。并且我更新到了最新的Android Studio(Arctic Fox 2020.3.1)。
Pub get完成,退出码为0。 Pub upgrade完成,退出码为0。 Pub outdated完成,退出码为0。 Flutter doctor -v报告:
[✓] Flutter(主频道,2.5.0-7.0.pre.105版本,在Mac OS X 10.15.7 19H1323 darwin-x64上,地区为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 Runtime Environment (build 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 - 为 Web 进行开发 • 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 Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] 已连接设备(1 可用) • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
• 未发现问题!
我已经关闭并重新打开了AndoidManifest文件。 我尝试了文件->无效缓存/重启。 我将文件->项目结构->项目项目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() {
}
有谁能帮我解决这个问题吗?
诚挚的问候,克里斯蒂安