android - 错误:未找到默认活动,但已声明
问题描述
我有两次发生在我身上的奇怪情况。
我的主模块中有清单 - igs_main
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.example">
<application
android:name=".CommonApplication"
android:allowBackup="false"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme"
android:supportsRtl="false"
tools:replace="android:supportsRtl,android:allowBackup"
tools:ignore="GoogleAppIndexingWarning, UnusedAttribute, RtlSupport">
<activity android:name=".auth.view.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
当我尝试启动我的应用程序时,它看起来像
我得到一个错误:
我尝试直接指定我的默认 Activity,但 AS 表示此 Activity 未在 Manifest 中声明。
然后我尝试了Invalidate Caches and Restart
AS 和Rebuild
项目,但它也没有帮助我。
所以,我浪费了所有可能的解决方案。谁知道如何修复?
解决方案
不知道为什么会和这个问题联系起来,但是这个问题的原因来自 Kotlin Compiler。当我启动 Kotlin 编译器选项时,我看到了警告,经过几秒钟的谷歌搜索后,我找到了此处描述的答案 - https://stackoverflow.com/a/50912853/4969827。
改成一切useProjectSettings
正常后true
!
为防止信息丢失,我将原始片段复制粘贴到此处。
<facet type="kotlin-language" name="Kotlin">
<configuration version="3" platform="JVM 1.6" useProjectSettings="true">
<compilerSettings />
<compilerArguments>
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
<option name="noStdlib" value="true" />
<option name="noReflect" value="true" />
<option name="moduleName" value="app_debug" />
<option name="addCompilerBuiltIns" value="true" />
<option name="loadBuiltInsFromDependencies" value="true" />
<option name="languageVersion" value="1.2" />
<option name="apiVersion" value="1.2" />
...
</compilerArguments>
</configuration>
</facet>
您必须阅读以下文字
然而问题不断出现。很少,但来了。有一天我在编辑 xml 文件时发现了损坏的 APPT。所以问题出在 SDK 中,我将其删除并再次安装。在此之后一切正常。
推荐阅读
- .net - IdentityServer4 - 刷新令牌混合流程 - Cookie 和存储
- python - ORtools 将学生安排到具有冲突时间表的课程
- sbt - 在 sbt 中查找另一个项目的 classDirectory
- angularjs - AngularJS 是否深度监视模板中的对象绑定?
- bash - 尝试测试未设置的变量,以及在调试模式下启动 Docker 入口点 Java 应用程序的特定值
- python - 有没有办法使用 read_sql_query 并且查询有 WHERE 列 = 变量?
- angular - 将项目更新到 Angular 8
- database - 在 Anylogic 中从数据库中读取数据
- pandas - 如何根据数据框列的条件进行比较?
- android - Android 应用程序中的语言翻译错误