Android Studio 无法解析来自 AAR 的符号 [英] Android Studio cannot resolve symbols from AAR

查看:75
本文介绍了Android Studio 无法解析来自 AAR 的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与使用.AAR文件的问题相同在其他项目中.但我想添加更多细节.因此出现了新问题.

My question has the same problem as Issue with using .AAR file in other project. But I want to add more details. Hence the new question.

我也知道这样的解决方案 Android Studio无法解析导入的 AAR 模块中的符号,但答案并不是我想要的.

I am also aware of solutions such as this Android Studio cannot resolve symbols from imported AAR module but the answers aren't exactly what I am looking for.

我可以毫无问题地将我的 AAR 文件添加到我的项目中,方法是将它添加到 libs/文件夹中或添加为新的 AAR 模块.当 AAR 作者提供更新的 AAR 时会出现问题(因为他们更改了公共 API 中的某些内容,即在旧方法之一中添加新参数).

I can add my AAR file into my project without problem either by adding it in libs/ folder or adding as new AAR module. The problem happens when the AAR authors give an updated AAR (because they changed something in their public API i.e. adding new parameter in one of the old methods).

Android Studio 似乎无法接受更改.在旧库中,我有这个方法调用:

Android Studio can't seem to pickup the changes. In the old library, I had this method call:

library.showText("hello");

作者发布了一个更新相同方法的新 API,应称为:

Authors released a new API with update to the same method, and should be called as:

library.showText("hello", 5000); // added timeout param

当我 CTRL+单击该方法时,它会将我带到该方法位于 C:\Users\MyUser\.gradle\caches\transforms-1\files-1.1\library.aar\. 的旧类..\旧的.class.我认为这就是为什么我收到无法解析符号"错误的问题.

When I CTRL+click the method, it takes me to the old class that has the method located in C:\Users\MyUser\.gradle\caches\transforms-1\files-1.1\library.aar\...\old.class. I think this is the problem why I get "cannot resolve symbols" error.

我该如何解决这个问题?

How do I fix this?

推荐答案

我猜问题是 Android Studio 和 Gradle 不同意.以下是三个对我有用的解决方案(经过数小时的测试).如果一个选项不适合您,请尝试下一个.

I guess the problem was Android Studio and Gradle did not agree. Here are three solutions that worked for me (after hours of tests). If one option does not work for you, try the next.

选项 1

  1. Gradle -> 刷新所有 Gradle 项目

选项 2

  1. Gradle -> 刷新所有 Gradle 项目
  2. 从项目中删除build"目录
  3. 从 C:\Users\YOUR_USER_NAME\.gradle\caches\transforms-1\files-1.1\* 中删除 .gradle 缓存(只删除几个最新的文件夹)
  4. 构建 -> 清理项目

选项 3(这将重新启动您的 Android Studio)

Option 3 (this will restart your Android Studio)

  1. 文件 -> 使缓存无效/重新启动
  2. 然后选择无效并重新启动
  3. Gradle -> 刷新所有 Gradle 项目

这篇关于Android Studio 无法解析来自 AAR 的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆