【问题标题】:Error: Activity class { } does not exist. Error while Launching activity错误:活动类 { } 不存在。启动活动时出错
【发布时间】:2017-11-13 01:49:00
【问题描述】:

我的简单“Hello World”应用程序在平板电脑三星 gt_3113(Android 4.2.2)上运行,但在我的手机 mi_4c(Android 5.1.1)上无法运行。我正在使用 Android Studio 2.2.2。为什么?

相关文件
AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.adc2017gmail.testmi4c">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

build.gradle

 apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.0"
        defaultConfig {
            applicationId "com.adc2017gmail.testmi4c"
            minSdkVersion 10
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.0.1'
        testCompile 'junit:junit:4.12'
    }

错误信息

11/27 16:01:54: Launching app
$ adb push C:\DREAM\TestMi4\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.adc2017gmail.testmi4c
$ adb shell pm install -r "/data/local/tmp/com.adc2017gmail.testmi4c"
Aborted 


$ adb shell am start -n "com.adc2017gmail.testmi4c/com.adc2017gmail.testmi4c.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.adc2017gmail.testmi4c/com.adc2017gmail.testmi4c.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.adc2017gmail.testmi4c/.MainActivity }
Error type 3
Error: Activity class {com.adc2017gmail.testmi4c/com.adc2017gmail.testmi4c.MainActivity} does not exist.

Error while Launching activity

我尝试重新安装驱动程序,

  • 清理项目
  • 删除了构建目录
  • 重新启动 Android Studio
  • 重建项目
  • 运行

从 Android Studio 2.2.2 跳转到 1.5.1

【问题讨论】:

  • 你用的是真机还是模拟器?
  • 我用的是真机:平板三星gt3113和智能手机mi 4c
  • 在运行项目之前,请尝试在您的设备中手动卸载该应用并重新安装。
  • 问题是该应用程序在Android 4.2.2(平板电脑)上运行。但是,Android Studio 2.2.2 在 Android 5.1.1 (mi_4c) 上运行时会出错。错误:活动类 { } 不存在。启动活动时出错
  • 创建apk文件并在mi_4c中设置后,应用运行(从Android Studio启动)

标签: android-activity launching


【解决方案1】:

我想你的设备是我的 LG Stylus 3 Android 7.0,当你按下并将应用程序从桌面移动到垃圾箱时,应用程序不会从设备中删除。详情请见my answer on the same question

【讨论】:

    猜你喜欢
    • 2018-07-24
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 1970-01-01
    相关资源
    最近更新 更多