昨天表现还好好地项目,今天一早运行报错:


error.png

[ +51 ms] Checking the license for package Android SDK Build-Tools 28.0.3 in /Users/ing/Library/Android/sdk/licenses
[ ] Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
[ ] Checking the license for package Android SDK Platform 29 in /Users/ing/Library/Android/sdk/licenses
[ ] Warning: License for package Android SDK Platform 29 not accepted.
[ +1 ms] FAILURE: Build failed with an exception.
[ +1 ms] * What went wrong:
[ ] Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
[ ] > Failed to install the following Android SDK packages as some licences have not been accepted.
[ ] build-tools;28.0.3 Android SDK Build-Tools 28.0.3
[ ] platforms;android-29 Android SDK Platform 29
[ ] To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.

错误大致意思应该是缺少某种许可。

题外话:

其实有个明显奇怪的地方,我本地AS的android sdk是我自己指定的路径:

【preferencs】-【android sdk】

并非错误中提示的 /Users/ing/Library/sdk. 为啥这里是这个路径呢,很显然在项目中的local.properties文件中指定成了sdk.dir=/Users/ing/sdk

也就是所谓的projectsdk 和你的androidstudiosdk的区别。所以我猜想直接修改文件中的路径为你设置的路径,重启as应该就能解决。

我暂时没去验证,想着就根据错误提示的信息看看能否解决,人家要求很明确,那我满足即可,终端依次输入:

cd /Users/你的用户名/Library/Android/sdkcd tools/bin./sdkmanager --licenses 

然后根据提示一路 y 即可,操作完成后还有报错【sorry,忘了截图了】,直接清缓存重启AS. 操作: File -- Invalidate caches/Restart
有意思的事情出现了

提示选择sdk路径

重启后会弹窗提示选择sdk路径,ok,基本证实了我之前的猜测。
将错就错,就任性的选择Use project's sdk ,然后build之后 重新运行不再报错,问题解决。
所以 这里碰到这个问题,首先确定下错误提示里的路径是否和你设置的android studio的sdk 的路径是一致的么,如果不是 那就直接修改local.properties里路径,改为android studio的路径,重启android studio即可。

!!! -- Import tips -- !!!

如果你和我一样,将错就错,改成了Android Studio的sdk路径并以后也用这个了,记得将bash_profile里的sdk路径也一并改掉,要不就和我似的,为了省磁盘空间把自定义路径下的sdk删除了的话,会导致无法连接真机。。。

以上是mac osx 系统下的解决办法,至于windows系统下这类报错,如果是旧版本的sdk,大致类似。首先根据提示找到对应的sdk路径的tools/bin下执行命令行工具里执行

sdkmanager.bat --licenses

但有的新版本下是没有该文件。那么有个简单的办法:直接打开sdk manager记得勾选show packages detial选项,然后勾选错误提示中的对应版本的sdk tools即可 【图是mac版的as截图,windows未实操,仅供参考】

mac as的设置页面

更多相关文章

  1. 给android添加系统属性
  2. Android(安卓)配置 之 AndroidManifest.xml 出错 Unable to inst
  3. android studio 2.1.1 启动abd出错
  4. Android(安卓)studio 修改SDK路径
  5. Android(安卓)SDK not found 的解决方案
  6. 在Eclipse 中关联android sdk 源代码
  7. Android(安卓)下载网络url文件并显示进度
  8. Android读取服务端TXT(JSON格式数据)返回汉字乱码的问题
  9. android读取SDCard任意路径下的文件

随机推荐

  1. 在Linux下搭建.net core开发环境教程
  2. 有关asp.net如何实现多个文件同时下载问
  3. 讨论在VS2015下使用EF框架的使用方法
  4. .net验证后台页面是否登录实例教程
  5. ScreenUnLock-图形解锁控件使用详解
  6. 基于MVC4+EasyUI开发附件上传组件uploadi
  7. 搭建Visual Stduio 2010开发环境的图文详
  8. 实例分析ASP.NET在MVC5中使用MiniProfile
  9. C#如何计算传入的时间距离今天的时间差的
  10. asp.net页脚制作详解