Android Studio中遇到的问题

  • 已有解决方法的
  • 1. 使用 makeJar 打包文件时出现 :app:lint 错误
  • 2. Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
  • 3. Android Build Error: resource android:attr not found
  • 4.Execution failed for task ':comp-account:kaptDebugKotlin'.
  • 5 The drawable "xxx" in drawable has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier


已有解决方法的

1. 使用 makeJar 打包文件时出现 :app:lint 错误

Execution failed for task ‘:app:lint’.
Lint found errors in the project; aborting build.

解决方法:
在将要打包的模块中的 build.gradle 文件中添加如下内容,并单击 sync now。

android {
  //...
  lintOptions {
      abortOnError false
  }
}

对应原因:
lint 进行代码检查,防止代码不规范—如使用了过时的 api。

2. Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

原因:自己的模块引用了某些高版本的东西,而主工程可能并没有那么适配那么高的版本,所以出错。
解决方法:要么升级主工程的版本(不推荐)要么改写依赖,用低版本的(其实主要出错的地方可能是自己引用的依赖里面又引用了某些依赖,导致最终版本汇总的时候出现了该问题,所以检查时不要只盯着自己显示引用的依赖,也可以去查查依赖中引用项是否有问题)。

3. Android Build Error: resource android:attr not found

原因:自己变异Android Studio工程时,会联网下载某些环境依赖(reactive的东西),如果远程的和本地的不一致,就会报这个错误,很难解决。
解决方法:同步两者的版本,将远端的环境配置整合好后拉取到本地即可解决该问题。

4.Execution failed for task ‘:comp-account:kaptDebugKotlin’.

错误情况:

androidstudio 铃声 android studio lint_解决方法


解决方法:

点击下方的蓝色提示字样,继续跑,就会出现报错位置信息了(PS:不一定每次都有效,有时候也米有对应的提示)

androidstudio 铃声 android studio lint_解决方法_02


androidstudio 铃声 android studio lint_Android_03

思考:
这个错误经常出现,由于他没有报错提示信息,所以很难定位。但是网上也有说这个错误的真正报错信息被Android Studio给隐藏起来了,需要点击左侧的所有报错信息,然后往上寻找就可以得到了(不管怎么样,这个错误多少会和xml相关,以至于很难提示到,所以出现该错误,先去改动后的xml文件中找找)
通解:
暂时未找到。。。。。

5 The drawable “xxx” in drawable has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier

怎么出现的?:更改图片资源后,突然出现该问题,并且其他地方的引用都会报错(找不到该文件)
解决方法:重启AS即可(…)