我有一个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

运行设置:


当前回答

如果你在AndroidManifest.xml中错误地设置了两个启动器Activity,也会出现这种情况:

    <activity android:name=".ActivityA">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:name=".ActivityB">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

只留下正确的LAUNCHER Activity

其他回答

我读了所有的“运行”日志,在那里我看到了这一行:

"Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space"

我的问题是,没有内部的空闲空间来安装应用程序。所以,我删除了一些文件,应用程序安装成功。

我得到了这个错误。我试图修复的错误(没有工作)是:

清洁项目 重建项目 重启Android Studio

解决方法很简单,只需卸载模拟器/手机上的应用程序,然后在Android Studio上点击“运行”即可。

SharedPreferences的文件名必须以当前样式的名称作为后缀,以防止产品的活动编译变体访问已定义用户的首选项 用于具有相同首选项名称的另一个活动编译。

尽管每个编译包都是不同的,但在使用flavorDimensions时,可能会交叉访问用户首选项,并在启动MainActivity时获得Error类型3

app.getSharedPreferences("${BuildConfig.FLAVOR}_shared_pref_3", Context.MODE_PRIVATE)

GL

如果你在智能手机上测试你的应用程序,它有24小时安全应用程序删除(如LG G6),你必须在设置中手动卸载应用程序,因为卸载后24小时它在bin中,所以Android Studio认为应用程序已经安装,但它在你的智能手机上的应用程序thrash中。

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.