'gradlew jar' fails

23 views
Skip to first unread message

Posri

unread,
May 19, 2023, 7:34:06 AM5/19/23
to Glide
Greetings Glide,

Sorry for the so basic question, but I followed the README.md to clone the repo, and when I run 'gradlew jar' I get warnings 'can't find referenced class java.lang.Class'.  I have my ANDROID_HOME set correctly (to build our other app).  The build fails with 'Execution failed for task ':annotation:compileJava'.  I have platforms android-30 ... android-33 installed in SDK Manager. 

I just want to run the samples like stated in the README.md.  I must be overlooking something simple, but I can't figure it out. 

Thanks for any tips.  Sincerely,

George

Róbert Papp (TWiStErRob)

unread,
May 19, 2023, 10:01:30 AM5/19/23
to Glide
Hi George,
I haven't been building Glide for a while, but as far as I know the annotation module is pure Java, no Android code.

Which JDK are you using? According to CI, it should be 11: https://github.com/bumptech/glide/blob/master/.github/workflows/build.yml#L15

Try setting JAVA_HOME=/path/to/jdk11 before you run the gradlew command.

If it doesn't work, please run `gradlew ...` with `--scan` argument, the "Build scan" link at the end helps to see the full context and error message(s).

Posri

unread,
May 19, 2023, 12:40:49 PM5/19/23
to Glide
Thank you Róbert!  I did specify JAVA_HOME like you said, but it still fails.  Here is the scan report: https://scans.gradle.com/s/rt55ftpggu3t2
Hopefully you see something obvious, I appreciate that you answered !

Sincerely, George

Róbert Papp (TWiStErRob)

unread,
May 19, 2023, 1:15:33 PM5/19/23
to Glide
I can't see it, sorry... and when I run that task or `gradlew jar` in general, it "just works". I'll give some info below that might help, but I'm clueless at this at the moment.

Yours:
:annotation:compiler:proguard FAILED
Note: there were 42 duplicate class definitions.
      (https://www.guardsquare.com/proguard/manual/troubleshooting#duplicateclass)
... 9MB of logs omitted
Warning: there were 69813 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (https://www.guardsquare.com/proguard/manual/troubleshooting#unresolvedclass)
Warning: there were 221 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (https://www.guardsquare.com/proguard/manual/troubleshooting#unresolvedprogramclassmember)

Mine:
> Task :annotation:compiler:proguard
Note: there were 42 duplicate class definitions.
      (https://www.guardsquare.com/proguard/manual/troubleshooting#duplicateclass)

The only thing I see different is Windows vs Linux and that you're running a JDK from an Android Studio/IntelliJ IDEA.

I have an older one:
...\java-11.0.2-x64-openjdk\bin>java -version
Picked up JAVA_TOOL_OPTIONS: -Xms32M -Xmx256M -XX:+UseG1GC -D-XX:+PrintCommandLineFlags
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

When I run with diagnostics on this task: `gradlew :annotation:compiler:proguard --rerun-tasks --info`, I get the below logs.
Try to compare what's different and remedy somehow.
In your 9MB of logs it is missing very basic Java classes like Object and String and List, which is just plain weird. I haven't seen that before in this context. Maybe try with another JDK 11.

> Task :annotation:compiler:proguard
Caching disabled for task ':annotation:compiler:proguard' because:
  Build cache is disabled
Task ':annotation:compiler:proguard' is not up-to-date because:
  Executed with '--rerun-tasks'.
Loading configuration file P:\projects\contrib\github-glide-v4\annotation\compiler\proguard.pro
ProGuard, version 7.1.0
Reading input...
Reading program jar [P:\projects\contrib\github-glide-v4\annotation\compiler\build\intermediates\repackaged.jar] (filtered)
Reading library jar [Z:\caches\gradle\caches\modules-2\files-2.1\com.squareup\javapoet\1.9.0\ecc5cf9c221d55481163e773b24336db149e51\javapoet-1.9.0.jar] (filtered)
Reading library jar [Z:\caches\gradle\caches\modules-2\files-2.1\com.google.auto.service\auto-service\1.0-rc3\35c5d43b0332b8f94d473f9fee5fb1d74b5e0056\auto-service-1.0-rc3.jar] (filtered)
Reading library jar [Z:\caches\gradle\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar] (filtered)
Note: duplicate definition of library class [javax.annotation.*]
Reading library jar [P:\projects\contrib\github-glide-v4\annotation\build\libs\annotation-4.16.0-SNAPSHOT.jar] (filtered)
Note: duplicate definition of library class [com.bumptech.glide.annotation.*]
Reading library jar [Z:\caches\gradle\caches\modules-2\files-2.1\com.google.auto\auto-common\0.3\4073ab16ab4aceb9a217273da6442166bf51ae16\auto-common-0.3.jar] (filtered)
Reading library jar [Z:\caches\gradle\caches\modules-2\files-2.1\com.google.guava\guava\19.0\6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9\guava-19.0.jar] (filtered)
Reading library jmod [P:\tools\lang\java-11.0.2-x64-openjdk\jmods\java.base.jmod] (filtered) <============================= This one contains the missing classes.
Reading library jmod [P:\tools\lang\java-11.0.2-x64-openjdk\jmods\java.logging.jmod] (filtered)
Reading library jmod [P:\tools\lang\java-11.0.2-x64-openjdk\jmods\java.compiler.jmod] (filtered)
Reading library jmod [P:\tools\lang\java-11.0.2-x64-openjdk\jmods\jdk.compiler.jmod] (filtered)
Reading library jmod [P:\tools\lang\java-11.0.2-x64-openjdk\jmods\jdk.unsupported.jmod] (filtered)
Note: there were 42 duplicate class definitions.
      (https://www.guardsquare.com/proguard/manual/troubleshooting#duplicateclass)
Initializing...
Ignoring unused library classes...
  Original number of library classes: 9656
  Final number of library classes:    502
Marking classes and class members to be kept...
Inlining subroutines...
Shrinking...
Removing unused program classes and class elements...
  Original number of program classes:            1875
  Final number of program classes:               212
Preverifying...
Writing output...
Preparing output jar [P:\projects\contrib\github-glide-v4\annotation\compiler\build\intermediates\proguarded.jar] (filtered)
  Copying resources from program jar [P:\projects\contrib\github-glide-v4\annotation\compiler\build\intermediates\repackaged.jar] (filtered)

BUILD SUCCESSFUL in 6s
7 actionable tasks: 7 executed

Posri

unread,
May 22, 2023, 7:13:38 AM5/22/23
to Glide
Dear Róbert, you are golden, THANK YOU!! 

Your observation, "that you're running a JDK from an Android Studio/IntelliJ IDEA" nailed it. 

I installed openjdk-11 and set my JAVA_HOME accordingly, (I have to have jdk 8, 19 installed also for other projects).  Now it works no issues. 

I appreciate your presence on this project and message board!

Sincerely, George

Róbert Papp (TWiStErRob)

unread,
May 22, 2023, 7:21:30 AM5/22/23
to Glide
Glad to hear it works now! Onwards to hacking the Glide sample :)

> Your observation, "that you're running a JDK from an Android Studio/IntelliJ IDEA" nailed it. 

This is why I asked for the Build Scan, it contains a ton of info, like on the Infrastructure page:
Java runtime
JetBrains s.r.o. OpenJDK Runtime Environment 11.0.13+0-b1751.21-8125866


It's still very weird that the IntelliJ embedded JDK, that is meant for developing Java apps, is not compatible with Java :)
Can you please check from which Android Studio / IDEA version you used the JDK? (I would like to try and reproduce it, and report if possible.)
You can read it from your original (broken) JAVA_HOME=p:\tools\ide\android-studio\jbr and next to the jbr folder there's a build.txt

Posri

unread,
May 22, 2023, 10:49:28 AM5/22/23
to Glide
It is this:

ctw01040@ctw01040-ThinkPad-T490:~$ cat /snap/android-studio/current/android-studio/jbr/release
JAVA_VERSION="17.0.6"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.jvmstat jdk.attach jdk.charsets jdk.compiler jdk.crypto.ec jdk.crypto.cryptoki jdk.dynalink jdk.hotspot.agent jdk.httpserver jdk.internal.ed jdk.internal.le jdk.internal.opt jdk.internal.vm.ci jdk.internal.vm.compiler jdk.internal.vm.compiler.management jdk.jartool jdk.javadoc jdk.jcmd jdk.jdeps jdk.jdwp.agent jdk.jdi jdk.jfr jdk.jlink jdk.jsobject jdk.localedata jdk.management jdk.management.agent jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.sctp jdk.security.auth jdk.security.jgss jdk.unsupported jdk.unsupported.desktop jdk.xml.dom jdk.zipfs"
SOURCE=".:git:f78d3aa21e90"
IMPLEMENTOR="JetBrains s.r.o."
OS_NAME="Linux"
OS_ARCH="x86_64"
LIBC="gnu"

I see it is java 17.  I thought previously it was Java 11.  Nonetheless, I had tried building it in the Android Studio IDE, and it compiled without errors but it wouldn't run on the emulator.  After applying your suggestion to install Java 11, the flickr sample now runs on the emulator.  It is thrilling to see.

Cheers, George
Reply all
Reply to author
Forward
0 new messages