首页 > 解决方案 > dexmaker gradle 同步失败,符号未解析

问题描述

我的 android studio 中的 gradle sync 一直失败。需要帮忙

https://github.com/linkedin/dexmaker这是我尝试使用的开源软件,名为 dexmaker。我尝试使用下载

androidTestCompile 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.21.0'

但它会出现这样的错误

Failed to resolve: com.linkedin.dexmaker:dexmaker-mockito-inline:2.21.1

我终于尝试了

androidTestCompile 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.19.1'

这有效,但在我的java代码中

问题是即使我成功同步 gradle,我仍然无法使用开源。

 DexMaker dexMaker = new DexMaker();

DexMaker 得到红线,如果我点击它,它会说

cannot resolve symbol 'DexMaker'

有什么问题?

标签: android

解决方案


我不确定,但据我了解您的情况:

您使用 androidTestCompile 指令添加依赖项。这意味着这个包将仅在 android 测试类中可用。为了更好地理解每个依赖项,可以通过三种方式添加:compile、testCompile 和 androidTestCompile。

  • compile :在您的应用程序代码中随处可见依赖关系。
  • testCompile :仅在常规测试中可用的依赖项。
  • androidTestCompile :仅在 android 测试中可用的依赖项。

因此,如果您希望该依赖项在您的应用程序中可用 - 将 androidTestCompile 替换为 compile。但我不确定你应该这样做,因为该库是用于测试的。

PS 不推荐使用编译指令,您应该使用 implementation、testImplementation 和 androidTestImplementation。


推荐阅读