每次尝试运行应用程序时都会出现错误:
“无法识别启动活动:找不到默认活动”。
我看到其他几个关于相同问题的帖子,但以下解决方案对我没用:
1. 使gradle缓存失效并重新运行 2. 手动在编辑配置选项卡中覆盖以选择默认活动(然后它会说“MainActivity未在AndroidManifest.xml中声明”,尽管实际上已经声明了!) 3. 同步gradle文件 4. 在清单文件中调整活动的顺序 5. 使用我的活动的长名称,但没有任何区别。
“无法识别启动活动:找不到默认活动”。
我看到其他几个关于相同问题的帖子,但以下解决方案对我没用:
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".