疑难杂症Unable to determine application id: com.android.tools.idea.run.ApkProvisionException(以解决)

问题来源

因为项目需要把旧版本as项目移植到新版本as里,并升级gradle及相关开发库。

升级参数:

相关升级参数升级前升级后
Android Studio2.2.2Dolphin | 2021.3.1 Patch 1
Android Plugin Version2.2.33.5.3
Gradle Version2.14.16.7.1
是否支持Androidx不支持支持并开启

迁移完后编译等各种报错全部解决,并且能正常打包,但就是无法通过调试直接在设备上进行安装,但调试的apk包是正常打出来了(且可以手动安装),具体报错看下面...

相关报错如下:

  1. Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant: general_display_online_ckxspDebug.
  2. ApkProvisionException: No outputs for the main artifact of variant: general_display_online_ckxspDebug.
  3. Execution failed for task ':infoShower_nj:installDebug'. >
    Failed to install on any devices.

相关网上的方法:

网上查询资料,得到如下解决方法:

  1. as和gradle版本不兼容,需要降级as版本。
  2. 修改Edit Configurations...博客
  3. 使用指令等方式 

 找了很久都没解决我的问题,依然是报一样的错误。

我的解决方法:

在app目录的build.gradle文件里,android.applicationVariants.all里的语句导致,移除即可。

移除前:

android {
...省略
android.applicationVariants.all { variant ->

        def buildType = variant.buildType.name
        def fileName//获取当前时间的"YYYY-MM-dd"格式。
        def createTime = new Date().format("YYYY-MM-dd", TimeZone.getTimeZone("GMT+08:00"))
        variant.outputs.all {
            if (buildType == "release") {
                ...省略
            }

            if (buildType == "debug") {
                variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/apks/${buildType}/${createTime}")
                fileName = "${buildType}版本_${variant.productFlavors[0].manifestPlaceholders.APP_NAME}_${variant.productFlavors[0].versionName}_${createTime}.apk"
                it.outputFileName = fileName
            }

        }
    }

移除这行代码即可:variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/apks/${buildType}/${createTime}")

移除后:

android {
...省略
android.applicationVariants.all { variant ->

        def buildType = variant.buildType.name
        def fileName//获取当前时间的"YYYY-MM-dd"格式。
        def createTime = new Date().format("YYYY-MM-dd", TimeZone.getTimeZone("GMT+08:00"))
        variant.outputs.all {
            if (buildType == "release") {
                ...省略
            }

            if (buildType == "debug") {
                fileName = "${buildType}版本_${variant.productFlavors[0].manifestPlaceholders.APP_NAME}_${variant.productFlavors[0].versionName}_${createTime}.apk"
                it.outputFileName = fileName
            }

        }
    }

总结

移除后,我的项目能调试时直接debug到指定设备上安装app,速度也提升了很多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
这种情况可能是由于对数据库进行查询时,方法内部缺少相应的参数占位符导致的。在持久层(Dao层)的方法中,应该使用@Param注解为每个参数添加占位符,以确保参数能够正确传递。例如,在Lmonkey_CartDao接口中的update方法中,参数quantity应该使用@Param("quantity")进行标注,u_id应该使用@Param("u_id")标注,p_id应该使用@Param("p_id")进行标注。这样就能避免出现"Parameter 'email' not found"的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Cause: org.apache.ibatis.binding.BindingException: Parameter ‘xx‘ not found.](https://blog.csdn.net/qq_54141095/article/details/124199713)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [数据库疑难杂症 java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the ...](https://download.csdn.net/download/weixin_38717896/13685038)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PYB3

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值