Android開発で、Gradleから以下のようなエラーが出た:
> Task :app:lint FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Could not resolve all artifacts for configuration ':${submodule}:debugAndroidTestRuntimeClasspath'.
> Could not resolve com.android.support:support-annotations:28.0.0.
Required by:
project :${submodule}
> Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints:
Dependency path '${project}:${submodule}:unspecified' --> 'com.android.support:support-annotations:28.0.0'
Constraint path '${project}:${submodule}:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following reason: debugRuntimeClasspath uses version 26.1.0
これはなにかというと、マルチモジュールなプロジェクトで依存関係を組んでいる時、
という状況で発生する。
すなわちやることはシンプルで、下位モジュールにも同様に設定すればいい。
今回の場合は、上位のモジュールで28.0.0が打たれているcom.android.support:support-annotations が、下位のモジュールではバージョンがunspecifiedになっているわけなので、その依存を追加すればいい:
... dependencies { implementation 'com.android.support:support-annotations:28.0.0' } ...