错误:活动类{}不存在。启动活动时出错

时间:2016-11-27 16:40:46

标签: android-activity launching

我的简单" Hello World"应用程序在平板电脑上运行Samsung 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

1 个答案:

答案 0 :(得分:0)

我想你有一个设备作为我的LG Stylus 3 Android 7.0,当你按下并将应用程序从桌面移动到垃圾箱时,应用程序不会从设备中删除。有关详细信息,请参阅my answer on the same question