Android Studio 中的错误,除非我每次都构建/清理

RJB*_*RJB 6 android android-studio

当我在 Android Studio 中重新运行我的应用程序时,我收到了一个随机错误列表,包括“运行应用程序”和“应用更改”。我必须清理和重建,然后它才能工作。像这样的错误:

Program type already present: androidx.transition.R

Duplicate resources

error: class BuildConfig is public, should be declared in a file named BuildConfig.java

Program type already present: androidx.recyclerview.R$drawable

Program type already present: androidx.lifecycle.extensions.R$style
Run Code Online (Sandbox Code Playgroud)

类型loadImageToStorage$2被定义多次:

为什么我不断收到这些消息?它极大地减慢了我的工作。

它似乎主要与重复资源有关,但是当我执行“构建”然后运行它时,它总是会清除。

我已经完全卸载了Android Studio,并重新安装,我仍然有同样的问题。在 mac 上运行。

非常感谢。

Son*_*rav 1

按列表顺序尝试以下方法:

  • Make Project从构建菜单中选择。
  • 转到File菜单并选择Invalidate Cache/restart
  • 将 gradle-wrapper.properties更改distributionUrl为其他版本(首选更高版本)。
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
  • 更新Android工作室。