我试图运行一个选定的构建变体,但在运行选项卡中给我以下错误,

无法确定应用程序id: com.android.tools.idea.run.ApkProvisionException:没有输出main artifact of variant: madhyapradesh-debug

所以请提出解决方案。


当前回答

确保您已经设置了applicationId com.example。Myapp”在你的build.gradle

android {
    ...
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    ...
}

从app ->编辑配置,确保你选择了“默认活动”

其他回答

你的Gradle不同步。去:文件->同步项目与Gradle文件。这应该能解决问题。

首先是清洁项目和重建项目。如果它不起作用,那么简单,硬核,快速的方法,这对我来说是有效的,只是在关闭IDE并重新启动它后删除下面两个名为。gradle和。idea的文件夹

确保您已经设置了applicationId com.example。Myapp”在你的build.gradle

android {
    ...
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    ...
}

从app ->编辑配置,确保你选择了“默认活动”

您需要更新Gradle版本: 转到文件->项目结构,然后更新Android Gradle插件版本和Gradle版本到最新的稳定版本(现在分别为7.0.2和7.2)

对我来说,解决方案显然是更新Gradle插件…