我有一个IntelliJ Android项目,我成功地导入到Android Studio 0.4.0。如果我不改变manifest中的任何东西,它就能很好地工作。然而,当我想要改变启动器活动并运行时,它会失败,并出现以下错误:

Launching application: com.trackingeng/LandingActivity.
DEVICE SHELL COMMAND: am start -D -n "com.trackingeng/LandingActivity"  
    -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN  
    cat=[android.intent.category.LAUNCHER] cmp=com.trackingeng/LandingActivity }
Error type 3
Error: Activity class {com.trackingeng/LandingActivity} does not exist.

当我点击同步项目与Gradle文件,它输出:

Project Sync
The project 'TrackingEng' is not a Gradle-based project

运行设置:


当前回答

以防有人遇到我的问题,而且没有其他的解决方案…… 我试图通过adb为FireTV启动一个活动,同时调试亚马逊启动器集成。然而,我的项目有60个不同的构建变体(多平台,多应用程序项目)和ApplicationId不匹配任何类路径,因为运行时包(和类路径)不同于ApplicationId。

我试着逃跑 adb shell am start -n com.myappid.example.packageone.packagetwo/com.myappid.example.packageone.packagetwo. mysplashactivity

(当然,我已经尝试了许多与com.runtimepath.example的组合,因为我在构建中遇到了不同applicationId的额外挑战。Gradle和另一个在运行时)

最后帮助的是这个帖子https://stackoverflow.com/a/36255727/5970652

这揭示了一种不同的格式! com.myappid.example / com.runtimepath.example.packageone.packagetwo.MySplashActivity

因此,如果您有不同的运行时类路径,请尝试使用构建指定。斜杠前面是gradle applicationId,斜杠后面是运行时类路径。

您还可以从BuildConfig中获取这些值。APPLICATION_ID和this.getLocalClassName()如果你想在logcat中记录它们。

其他回答

我通过简单地删除app ->构建文件夹,然后重建项目来解决这个问题。构建文件夹将在项目构建后自动重新创建,因此删除它没有风险。

重构活动启动器并更改类名。

Had the same error, with a much newer version of Android Studio (version 4.1) . A fresh install of Android Studio + a fresh "basic Activity" template would run into error type 3 for hours. I am on win 10 - my problem was how to kill the gradle cache. A good answer above showed a screen snapshot from gradle, but i didn't find it in Android Studio 4.1. Also the env vars for gradle had not been set , and the commandline for gradle didn't work. So .. here is how it worked finally. I went to C:\Users\myusername\ .gradle. This has subdir "caches". I deleted everything inside. Worked ! I did close Android Studio before, restarted and then it worked nicely. Ah forgot one thing- i run the device emulator (defauöt device), i.e. no physical device yet.

我有错误类型3。我设法通过在AndroidMainfest.xml中添加以下代码来修复它。

    <activity android:name=".GameActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

正如其他人所注意到的,这个问题可能是由卸载应用程序时附加的设备/模拟器引起的,而As连接仍然存在。在我这边,我只是删除了项目中的所有构建文件夹(在app和project dirs下),并在设备/模拟器上重新启动应用程序。