You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kotlin应用构建后无法在Android Studio模拟器启动如何解决

问题描述

我是Android移动应用开发领域的新手,编写的Kotlin应用构建完成后,没有出现在Android Studio模拟器(Pixel XL API 30: Android 11.0 (Google API))中。
ADB无法对该应用进行调试,执行如下命令时出现报错:

$ adb shell am start -n "paris.ksainthi.soundpark/paris.ksainthi.soundpark.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Timed out waiting for process (paris.ksainthi.soundpark) to appear on Pixel_XL_API_30 [emulator-5554].

该应用存在于配置的应用列表中,但是没有出现在模拟器主页,也没有正常启动。

项目配置信息

build.gradle配置

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 31
    buildToolsVersion '30.0.2'

    defaultConfig {
        applicationId "paris.ksainthi.soundpark"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.google.android.material:material:1.5.0-alpha02'
}

运行配置

  • Deploy: Default APK
  • Launch: Specified Activity,指定为paris.ksainthi.soundpark.MainActivity
解决步骤
  • 排查AndroidManifest.xml配置
    确认MainActivity节点已经正确配置了启动器的intent-filter,正确配置示例如下:
<activity
    android:name=".MainActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

注意API 30及以上版本必须给可被外部调用的Activity显式设置android:exported="true",否则不会出现在启动器列表中。

  • 修复依赖冲突
    build.gradle中引入了两个版本的Material组件库,分别是稳定版1.4.0和测试版1.5.0-alpha02,版本冲突会导致运行异常。删除其中重复的依赖,建议保留稳定版1.4.0,删除implementation 'com.google.android.material:material:1.5.0-alpha02'这行配置。
  • 对齐SDK版本
    当前compileSdk为31,targetSdk为30,版本不一致可能引发兼容问题。可以将compileSdkVersion修改为30,和targetSdkVersion保持一致,降低兼容风险。
  • 清理缓存重试
  1. 执行命令adb uninstall paris.ksainthi.soundpark卸载模拟器中残留的应用包
  2. 冷启动模拟器,不要使用快速启动的快照
  3. 点击Android Studio菜单File->Invalidate Caches,清空缓存后重启IDE,重新构建项目运行
  • 排查运行时异常
    如果以上操作都无效,打开Android Studio的Logcat面板,筛选当前应用的日志,查看启动过程中是否有崩溃报错,根据具体的异常信息进一步定位问题。

内容的提问来源于stack exchange,提问作者ksainthi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 04:15:03