如何解决默认活动未找到的问题?

huangapple go评论62阅读模式
英文:

How to fix the default activity not found problem?

问题

我的问题与Android Studio有关。每当我尝试运行我的应用程序时,都会出现一个错误,上面写着“找不到默认活动”。请帮我解决,这真的很重要。提前谢谢!
以防万一,我有两个类:第一个是MainActivity,第二个是CatRepository。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.cats">
    <uses-permission android:name="android.permission.INTERNET"/>
    <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=".ui.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
英文:

my problem is related to Android Studio.Whenever I try to run my app I get an error that says default activity not found.Please help me out,it's really important.Thank you in advance!
Just in case,I've got 2 classes: the first one is MainActivity,the second one is CatRepository

&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
package=&quot;com.example.cats&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;
&lt;application
    android:allowBackup=&quot;true&quot;
    android:icon=&quot;@mipmap/ic_launcher&quot;
    android:label=&quot;@string/app_name&quot;
    android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
    android:supportsRtl=&quot;true&quot;
    android:theme=&quot;@style/AppTheme&quot;&gt;
    &lt;activity android:name=&quot;.ui.MainActivity&quot;&gt;
        &lt;intent-filter&gt;
            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;

&lt;/manifest&gt;

答案1

得分: 1

尝试将 &lt;activity android:name=&quot;.ui.MainActivity&quot;&gt; 替换为 &lt;activity android:name=&quot;.MainActivity&quot;&gt;

英文:

Try to replace &lt;activity android:name=&quot;.ui.MainActivity&quot;&gt; by &lt;activity android:name=&quot;.MainActivity&quot;&gt;

答案2

得分: 0

尝试使用您的 Activity 的完整包名称。

英文:

Try putting full package name of your Activity.

答案3

得分: 0

尝试无效化缓存并重新启动。
文件 -> 无效化缓存/重新启动

此外,在执行此操作后,同步您的项目:文件 -> 与Gradle文件同步项目

英文:

You can try invalidating cache and restart.
File -> Invalidate Cache/Restart

Also after doing this, sync your project. : File-> Sync Project with Gradle Files

huangapple
  • 本文由 发表于 2020年8月31日 03:51:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/63661544.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定