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

查看:424
本文介绍了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 \中的旧类. .\ old.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.

我该如何解决?

推荐答案

我想问题是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. 从项目中删除构建"目录
  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天全站免登陆