acorn icon indicating copy to clipboard operation
acorn copied to clipboard

Gradle dependency issue in java module

Open VincentJian opened this issue 5 years ago • 4 comments

Cannot resolve reference com.nhaarman.acorn.presentation.Container class when using in pure java module.

Steps to reproduce:

  1. Create empty activity project using Android Studio wizard
  2. Create module Java Library
  3. Add implementation 'com.nhaarman.acorn.ext:acorn:1.2.0' to the java module in build.gradle file
  4. Create any interface that extends com.nhaarman.acorn.presentation.Container will see the error.

Found a similar issue on StackOverflow. Maybe it is gradle issue then.

VincentJian avatar Jan 02 '20 06:01 VincentJian

Hi @VincentJian, I was unable to reproduce this. Is this still an issue?

nhaarman avatar Feb 02 '20 15:02 nhaarman

Yes, it is still an issue. This issue only happens in pure java module. In the last step, I mean create the interface in the java module.

VincentJian avatar Feb 03 '20 06:02 VincentJian

I followed your steps and I had no errors. I implemented both no .ext and .ext versions. I think you have a broken gradle version or you IDE needs clear cache.

programadorthi avatar Jun 15 '20 12:06 programadorthi

I tried again with gradle 6.5 with Android Studio 4.0 and still see this issue. I also tried invalidate and restart the IDE. Here is the build.gradle file in my pure java module.

apply plugin: "java-library"
apply plugin: "kotlin"

compileKotlin {
  kotlinOptions.jvmTarget = "1.8"
}

dependencies {
  implementation fileTree(dir: "libs", include: ["*.jar"])
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
  implementation "com.nhaarman.acorn.ext:acorn:1.2.4"
}

Anyway, I convert this pure java module to android library module and this issue is gone.

VincentJian avatar Jun 18 '20 02:06 VincentJian