错误类型3:活动类{...}不存在

Cha*_*ham 30 android android-manifest

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.m.e"
      android:versionCode="5"
      android:versionName="3.0">

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18"/>

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

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
    <activity
            android:name="com.m.e"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action
                    android:name="android.intent.action.MAIN"
                    />

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity
            android:name="com.m.e"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action
                    android:name="android.intent.action.first"
                   />

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>

    .....

</application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

错误:

 Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.m.e/.Splash }
 Error type 3
 Error: Activity class {com.m.e/com.m.e.Splash} does not exist.
Run Code Online (Sandbox Code Playgroud)

注意: .Splash 确实存在.

Cha*_*ham 29

build.gradle,行:

 apply plugin: 'android-library'
Run Code Online (Sandbox Code Playgroud)

需要改为:

 apply plugin: 'com.android.application'
Run Code Online (Sandbox Code Playgroud)

  • 如何应用插件:'android-library'甚至出现在你的build.gradle中? (4认同)
  • 对我来说,我不得不替换apply plugin:'android'(我被警告现在已被弃用),使用apply plugin:'com.android.application'并且错误消失了,它似乎无处不在,虽然这很有趣 (3认同)

Blu*_*ift 21

重命名/重构后我遇到了同样的错误.我所做的是将applicationIdproperty属性添加到我的build.gradle文件中,并将其值设置为应用程序包.像这样:

android{
    defaultConfig{
        applicationId "com.example.mypackage"
    }
}
Run Code Online (Sandbox Code Playgroud)


Sha*_*law 18

虽然这是几年前发布的问题,但我想分享我的解决方案.

打开运行 - >编辑配置,检查是否在包面板中选择了"部署默认APK".应该选择"部署默认APK".

问题发生在我身上,因为我之前由于某种原因选择"不要部署任何东西",我忘了撤消所选择的.


Win*_*der 12

adb uninstall <your package name>
Run Code Online (Sandbox Code Playgroud)

这对我有用.虽然应用程序甚至没有显示为已安装的应用程序,但卸载命令修复了问题.我的理论:在上次卸载之后,可能有些数据未被清除,导致下一次安装未完全完成.


ral*_*abb 8

是的,我知道已经有一个可接受的答案,但是它不起作用(或者可能不再起作用)。当前在Android 8.0 Oreo版本上,有可能您的应用程序可能会在设备上卸载,但“并非针对所有用户”。因此,下次您使用设备调试应用时,就会发生此错误。

Error: Activity class "class path here" does not exist
Error type 3
Run Code Online (Sandbox Code Playgroud)

这是您如何修复绝对有效的方法(已搜索2天,请相信我)

  1. 如果您仍然可以在“设置”>“应用程序”>“选择”下查看您的应用程序,然后转到其工具栏上的选项,然后选择“ 为所有用户卸载

  2. 如果您的应用程序不在“应用程序”列表中,请生成/构建一个APK,在我的情况下(Android Studio 3.0.1),您可以转到Build> Build Apk。在您的设备上手动安装。然后执行步骤1

那里 !您的应用程序已全部清除,并且已完全卸载。您现在可以在开发环境中对其进行调试。

有待进一步研究:我相信Samsung Pass应用程序与此错误有关。即使卸载后。我的项目仍在他们的清单上。

快乐的编码欢呼!

  • 这个答案值得一个*英雄*奖......简直难以置信。 (2认同)

Yas*_*jdi 8

这就是我固定的方式。转到gradle>任务>安装> UninstallAll

在此处输入图片说明

  • 我尝试了一切。但这对我有用。多谢 (2认同)

Ani*_*hal 5

转到设备设置。选择应用程序选项,从列表中选择该特定应用程序,在右上角,选择菜单栏选项,然后为所有用户选择删除。它为我工作。


Han*_*man 5

我也遇到了同样的问题,当我卸载应用程序并且同时给出构建时出现了问题.然后在工作室中给出了上述错误.所以我尝试了所有选项,但那些不适用于我.所以我查了一下在设置 - >应用程序 - >选择我的应用程序,我看到应用程序处于禁用状态,所以它没有安装(给出错误).我卸载了应用程序并尝试构建然后它工作正常.


小智 5

我尝试了上面的所有建议,但只有这解决了我的问题;

  1. 更改包名称无关和同步gradle.
  2. 将包名更改为您想要的,同步和运行.


Gop*_*iar 5

我在Android O(Google Pixel C)上收到此错误。我想我也会在其他设备上安装此错误。

我试图从AndroidStudio安装到任何设备都很好,但是没有在Android O上安装。在Android o上,我遇到了相同的错误(如下所示)。

根本原因。我在该设备上有两个用户(user1,user2)。当我从user1卸载应用程序时(该应用程序仍在user2中)。当我尝试在user1上重新安装应用程序时,它会返回错误。在user2中相同。如果我同时从两个用户都卸载了该应用程序并重新安装,则可以解决此问题。

从命令链接开始,如果我们使用“ adb install -r example.apk”,则可以运行,但是AndroidStudio不会卸载并重新安装(如果设备中有两个用户)。

因此,就我而言,这是由于多个用户问题造成的。我所有其他设备(Android O除外)都是单用户,这就是为什么它可以在其他设备上运行,但Pixel C除外(有两个用户)。因此,请注意多用户设备。

No apk changes detected since last installation, skipping installation of /home/user/Project/AndroidStudioProjects/MyAddress/app/build/outputs/apk/app-debug.apk
$ adb shell am force-stop com.arris.myaddress
$ adb shell am start -n "com.example.address/com.example.address.MainActivity1" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.example.address/com.example.address.MainActivity1" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.address/.MainActivity1 }
Error type 3
Error: Activity class {com.example.address/com.example.address.MainActivity1} does not exist.

Error while Launching activity
Run Code Online (Sandbox Code Playgroud)