小编Gre*_*g M的帖子

“无法识别启动活动:未找到默认活动” - Android Studio - 没有有效答案

每当尝试运行应用程序时,都会出现错误:

“无法识别启动活动:找不到默认活动”。

我已经看到了关于同一问题的其他一些线程,但以下解决方案对我不起作用:

  1. 使gradle缓存失效并重新运行
  2. 在编辑配置选项卡中手动覆盖以选择默认活动(然后它会显示“活动'MainActivity'未在AndroidManifest.xml中声明”,即使它是!)
  3. 重新同步 gradle 文件
  4. 实际上是在我的清单中调整活动的顺序
  5. 我的活动使用长名称,但没有任何区别
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mywebname">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ListenScreen"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="portrait">
        </activity>

 </application>

</manifest>
```

As you can see, I have clearly declared the activities (my app only has 2 so far), and I've put the intents around the ".MainActivity".
Run Code Online (Sandbox Code Playgroud)

android android-studio

3
推荐指数
1
解决办法
8150
查看次数

标签 统计

android ×1

android-studio ×1