DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.19k stars 1.51k forks source link

Glide Annotations library not included in classpath at build time #844

Open jakubgs opened 2 years ago

jakubgs commented 2 years ago

We're trying to use react-native-fast-image in https://github.com/status-im/status-react/pull/12769 and I've identified a very weird build issue.

Our compilation using Gradle 5.6.4 fails with:

> Task :react-native-fast-image:compileReleaseJavaWithJavac FAILED
/build/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:8: error: package com.bumptech.glide.annotation does not exist
import com.bumptech.glide.annotation.GlideModule;
                                    ^
/build/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:32: error: cannot find symbol
@GlideModule
 ^
  symbol: class GlideModule
/build/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageGlideModule.java:3: error: package com.bumptech.glide.annotation does not exist
import com.bumptech.glide.annotation.GlideModule;
                                    ^
/build/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageGlideModule.java:7: error: cannot find symbol
@GlideModule
 ^
  symbol: class GlideModule
4 errors

And by running Gradle with --debug I've found out that the javac flags were incorrect. Specifically:

javac -source 1.7 -target 1.7 -d /tmp/status/node_modules/react-native-fast-image/android/build/intermediates/javac/release/classes -encoding UTF-8 -bootclasspath /nix/store/b36sawh7ksaq55cq52fhy5px8ir72gra-androidsdk-mod-sdk/platforms/android-30/android.jar -g -sourcepath '' -processorpath /nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/github/bumptech/glide/compiler/4.12.0/compiler-4.12.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/github/bumptech/glide/annotations/4.12.0/annotations-4.12.0.jar -s /tmp/status/node_modules/react-native-fast-image/android/build/generated/ap_generated_sources/release/out -XDuseUnsharedTable=true -classpath /run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/1e75a64a191db09e1a8f30783a04e76c/jetified-react-native-0.63.4-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/github/bumptech/glide/glide/4.12.0/glide-4.12.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/github/bumptech/glide/okhttp3-integration/4.12.0/okhttp3-integration-4.12.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/facebook/infer/annotation/infer-annotation/0.11.2/infer-annotation-0.11.2.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/javax/inject/javax.inject/1/javax.inject-1.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/ac96f13c1d6b3201941b526b03f95001/appcompat-1.0.2-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/d5023d0a355e963d986891e69aa4c1d5/fragment-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/e82b5274791941e8c5282ad169deb5ad/vectordrawable-animated-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/40e5b6e9cc698ca60b30e1daf1af8e8c/legacy-support-core-ui-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/f99382d2d241baa477c8b2af4f1cb450/swiperefreshlayout-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/7544f3b79f887993819d03e427debb4f/legacy-support-core-utils-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/899a47339e6e3b83d10a80aade2664e5/vectordrawable-1.0.1-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/71aa4158d7995a35b5edb1b0f0de02f9/loader-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/7c6ec2932e93b660c1a888fb3838854a/viewpager-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/9011184677e96b5f555f8a44ff71f5d7/coordinatorlayout-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/0eb3d10d3afdc845ea3c6efd195df1a7/drawerlayout-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/f5cedf641a563cefda2535d34b0090b0/slidingpanelayout-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/02d62ddd2538aa94e810078c7907fdca/customview-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/58483e41de5ef771da037f4a94882ab4/asynclayoutinflater-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/f767ac3ec1c6803cdafa6a8be2796252/core-1.0.1-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/76262ed5ccb14334e6689dc6682918c6/versionedparcelable-1.0.0-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/androidx/collection/collection/1.0.0/collection-1.0.0.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/46e710b2d01afa262e3d9c0e6fd304b1/cursoradapter-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/6a1dc7f8afc0e926158680484174737c/interpolator-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/10c3f6ec0c6f8c86ec829f8e2a79ed45/lifecycle-runtime-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/4158195cce70e46c2776dd659bb45d17/documentfile-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/b335028dc3f7c6dbfd257f11b38cb7f7/localbroadcastmanager-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/d5f5e7ab474d0c933b63ad358b9c2fea/print-1.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/f7ec0dd8f964886d74c5c58450e9e8f4/lifecycle-viewmodel-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/203b70d623eac66ad56b9353e476ee20/lifecycle-livedata-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/6c7f228808742457ee6aa50ca0d1d831/lifecycle-livedata-core-2.0.0-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/androidx/lifecycle/lifecycle-common/2.0.0/lifecycle-common-2.0.0.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/3c1604c471424c396bf4cd133668f1ae/core-runtime-2.0.0-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/androidx/arch/core/core-common/2.0.0/core-common-2.0.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/androidx/annotation/annotation/1.0.0/annotation-1.0.0.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/4ad733edfc8fc65899795cdb7fe6aad3/fresco-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/32e588cfd99fe81e279be76ed2ca32f5/jetified-fbcore-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/67452b509981aa1e1be9f45edf5cb08a/drawee-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/2e8fab79df75e2d64af4ee43281f982b/imagepipeline-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/f4b06160d75bdf7759742fd201f4b531/imagepipeline-base-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/9e84b3e82c9f19233eb9a095b1b9e812/soloader-0.9.0-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/facebook/soloader/annotation/0.9.0/annotation-0.9.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/facebook/soloader/nativeloader/0.9.0/nativeloader-0.9.0.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/8a0171500056b7f17f069987c38b6746/nativeimagefilters-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/53f2bb4d9e3c666b68890b34dc843b79/nativeimagetranscoder-2.0.0-api.jar:/run/user/1000/tmp.NhnslRScb7/caches/transforms-2/files-2.1/068cb46e6ca8fcb031ee4744abbee622/imagepipeline-okhttp3-2.0.0-api.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/squareup/okhttp3/okhttp-urlconnection/3.12.12/okhttp-urlconnection-3.12.12.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/squareup/okhttp3/okhttp/3.12.12/okhttp-3.12.12.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/squareup/okio/okio/1.15.0/okio-1.15.0.jar:/nix/store/14mv613575d7sv9xljdh0nn1mzm4m930-status-react-maven-deps/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.jar:/tmp/status/node_modules/react-native-fast-image/android/build/intermediates/compile_only_not_namespaced_r_class_jar/release/R.jar /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageRequestListener.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageCacheControl.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewPackage.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewConverter.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageProgressListener.java /tmp/status/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java /tmp/status/node_modules/react-native-fast-image/android/build/generated/source/buildConfig/release/com/dylanvann/fastimage/BuildConfig.java

In this example we can see that:

If I run the command manually but add the JAR path to -classpath compilation works. For some reason Gradle understands that annotations is a dependency on compiler, but misses that it's a dependency on glide.

jakubgs commented 2 years ago

Running this before build fixes the issue:

sed -i '65 i implementation "com.github.bumptech.glide:annotations:${glideVersion}"' node_modules/react-native-fast-image/android/build.gradle

But that's hardly a proper fix.

jakubgs commented 2 years ago

Right now the dependencies section of android/build.gradle looks like this: https://github.com/DylanVann/react-native-fast-image/blob/4d8c74945df460bd89ad2bb74c86efb6ccf76c48/android/build.gradle#L62-L68 https://github.com/DylanVann/react-native-fast-image/blob/v8.5.11/android/build.gradle#L62-L68

Before it looked like this: https://github.com/DylanVann/react-native-fast-image/blob/df37c4f7b2b376d5bc8cfd92a5ae20cef091e17e/android/build.gradle#L59-L70 https://github.com/DylanVann/react-native-fast-image/blob/v8.5.0/android/build.gradle#L59-L70

As we can see an explicit reference to com.github.bumptech.glide:annotations has been dropped in: https://github.com/DylanVann/react-native-fast-image/commit/1f04c5542c6138d58446c58c3f3a5614772f81f1

jakubgs commented 2 years ago

As expected, downgrading to 8.5.0 fixes the build issue. So as far as I can tell the removal of the:

     implementation("com.github.bumptech.glide:annotations:${_glideVersion}") 

line has broken builds for FastImageOkHttpProgressGlideModule.java