当前位置:   article > 正文

Kotlin源码编译报错,提示@UnsupportedAppUsage和@SystemApi声明的Java函数无法调用_none of the following functions can be called with

none of the following functions can be called with the arguments supplied.

今天遇到一个Kotlin源码编译问题。在Kotlin代码中调用AppOpsManager的setMode方法

提示error: none of the following functions can be called with the arguments supplied: 

@UnsupportedAppUsage public open fun setMode(code: Int, uid: Int, packageName: String!, mode: Int): Unit defined in android.app.AppOpsManager

@SystemApi public open fun setMode(op: String!, uid: Int, packageName: String!, mode: Int): Unit defined in android.app.AppOpsManager

查看一下AppOpsManager的源码,setMode()方法已经被@UnsupportedAppUsage和@SystemApi注解声明。

在Kotlin代码调用,然后Android源码编译,报错如下:

  1. AppUsageAccessDao.kt:150:36: error: none of the following functions can be called with the arguments supplied:
  2. @UnsupportedAppUsage public open fun setMode(code: Int, uid: Int, packageName: String!, mode: Int): Unit defined in android.app.AppOpsManager
  3. @SystemApi public open fun setMode(op: String!, uid: Int, packageName: String!, mode: Int): Unit defined in android.app.AppOpsManager
  4. mAppOpsManager.setMode(
  5. ^
  6. 15:51:33 ninja failed with: exit status 1
  7. #### failed to build some targets (30 seconds) ####

 解决办法:在java代码中调用setMode,成功编译。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/334584
推荐阅读
相关标签
  

闽ICP备14008679号