2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

kotlinでbuild.gradleにimplementationを追加しているのにUnresolved referenceになる

Posted at

はじめに

kotlinを書くのに依存関係を追加することは多くありますが、そこで発生するエラーについてあまり私が検索したやり方では解決方法が見つからなかったのでまとめます

(検索方法が悪い可能性もありますが、、)

問題

build.gradleに新しくimplementationを追加して、importしたのに何故かUnresolved referenceでIntelliJ上で赤線が引かれてしまうことがあります

もちろん実行もエラーになってしまいます

こんな感じ

image.png

(実際にtestはないです)

解決方法

依存関係がうまく反映されていないので、今ダウンロードしている依存ファイルをすべて削除してもう一度入れ直すと治ります

$ rm -rf ~/.gradle/caches
$ rm -rf ~/.gradle/daemon

このコマンドを叩くとIntelliJが再ダウンロードを始めます
少し長いですが待つとエラーが消えていると思います

おわりに

これを知らずに何度も苦しめられました
理解すれば簡単に対処できるようになりましたが、初心者にはいきつくまで時間がかかりました

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?