react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

Conflicting android two glide modules

Open in4core opened this issue 7 years ago • 13 comments

Hi when we use react-native-webview that needs to android.useAndroidX=true android.enableJetifier=true

fast-image build broken (errors below)

Task :react-native-fast-image:processDebugAnnotationsWithJavac FAILED /Users/in4core/Documents/mac_prj/ednaRn/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:6: error: package android.support.annotation does not exist import android.support.annotation.NonNull; ^ /Users/in4core/Documents/mac_prj/ednaRn/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:41: error: cannot find symbol @NonNull Context context, ^ symbol: class NonNull location: class FastImageOkHttpProgressGlideModule /Users/in4core/Documents/mac_prj/ednaRn/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:42: error: cannot find symbol @NonNull Glide glide, ^ symbol: class NonNull location: class FastImageOkHttpProgressGlideModule /Users/in4core/Documents/mac_prj/ednaRn/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java:43: error: cannot find symbol @NonNull Registry registry ^ symbol: class NonNull location: class FastImageOkHttpProgressGlideModule /Users/in4core/Documents/mac_prj/ednaRn/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageRequestListener.java:34: error: package android.support.annotation does not exist public boolean onLoadFailed(@android.support.annotation.Nullable GlideException e, Object model, Target target, boolean isFirstResource) { ^


We also try everything

ext { excludeAppGlideModule = true }

buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" googlePlayServicesVersion = "+" // default: "+" firebaseVersion = "+" // default: "+" excludeAppGlideModule = true }

also

project.ext.react = [ entryFile: "index.js", ]

ext { excludeAppGlideModule = true } project.ext { excludeAppGlideModule = true }


Error also appear

in4core avatar May 22 '19 17:05 in4core

Same issue on react-native v0.60.0 RC 0 Unable to get it working on android.

immortalx avatar Jun 03 '19 02:06 immortalx

same here --- Update --- Since rollback from old version of react-native-webview didn't work for me as well it affect the react-native-gesture-handler, I decided to use the latest version of rn-webview. What I did was manually modified all Old artifact to the latest AndroidX Migration Detail for Androidx.

Before you read the solution keep note that this is the last resort needed if you decided to go for Androidx. We still need to wait for all module owners to adapt on AndroidX for the official packages release.

For rn-fast-image I manually changes this files (NOTE: this might work or might not work for other people and still might show new errors, Please Backup your files)

\node_modules\react-native-fast-image\android\build.gradle
\node_modules\react-native-fast-image\android\src\main\java\com\dylanvann\fastimage\FastImageOkHttpProgressGlideModule.java

I manually change this code(s) import android.support.annotation.NonNull to import androidx.annotation.NonNull

Also you might experience the Glide issue which still use the old code. which is why I updated the build.gradle.

First I update the Glide version to 4.9.0 def _glideVersion = safeExtGet("glideVersion", "4.9.0") then I also add this in the dependency annotationProcessor 'androidx.annotation:annotation:1.0.0' this will force to use the androidx for Glide build files.

Also you need to do this to the other module packages you use on your RN project. Besure to located Old Android import and use the latest AndroidX.

thanks,

eggybot avatar Jun 03 '19 20:06 eggybot

I am also experiencing this issue. It's just a matter of migrating the project to AndroidX support library.

An additional problem is that the module generates .java files at build time, which in turn make use of e.g. android.support.annotation.NonNull. This is the reason why you can't just manipulate the module's files and be done with it.

For now, as a workaround, I left the module's files untouched, created a gradle.properties inside /node_modules/react-native-fast-image/android and thus deactivated AndroidX and Jetifier for this module only:

android.useAndroidX=false
android.enableJetifier=false

thewirv avatar Jun 04 '19 13:06 thewirv

I am also experiencing this issue. It's just a matter of migrating the project to AndroidX support library. An additional problem is that the module generates .java files at build time, which in turn make use of e.g. android.support.annotation.NonNull. This is the reason why you can't just manipulate the module's files and be done with it. For now, as a workaround, I left the module's files untouched and created a gradle.properties inside /node_modules/react-native-fast-image/android and deactivated AndroidX and Jetifier for this module:

android.useAndroidX=false
android.enableJetifier=false

Its not a workaround because more and more modules such as WebView use useAndroidX=true NOW!!!

that's why I'm currently only deactivating it for this module

thewirv avatar Jun 04 '19 13:06 thewirv

@Mazzel-13 thanks for the suggested workaround. Are you using Proguard? I'm getting the following seemingly related errors after disabling AndroidX and Jetifier:

Warning: com.dylanvann.fastimage.GlideApp: can't find referenced method 'com.bumptech.glide.RequestManager with(android.support.v4.app.FragmentActivity)' in program class com.bumptech.glide.Glide
Warning: com.dylanvann.fastimage.GlideApp: can't find referenced method 'com.bumptech.glide.RequestManager with(android.support.v4.app.Fragment)' in program class com.bumptech.glide.Glide

mrubens avatar Jun 05 '19 16:06 mrubens

@Mazzel-13 thanks for the suggested workaround. Are you using Proguard? I'm getting the following seemingly related errors after disabling AndroidX and Jetifier:

Warning: com.dylanvann.fastimage.GlideApp: can't find referenced method 'com.bumptech.glide.RequestManager with(android.support.v4.app.FragmentActivity)' in program class com.bumptech.glide.Glide
Warning: com.dylanvann.fastimage.GlideApp: can't find referenced method 'com.bumptech.glide.RequestManager with(android.support.v4.app.Fragment)' in program class com.bumptech.glide.Glide

I am not using Proguard. Somehow I can't get it minifying to work unfortunately, but that's an issue that I'll be investigating later.

thewirv avatar Jun 06 '19 09:06 thewirv

Following @Mazzel-13 suggestion worked, but it's something painful. In my case I had to create gradle.properties in 4 different libraries node_modules/{react-native-broken-lib}/android to get build work.

rochapablo avatar Jun 11 '19 14:06 rochapablo

None of this has worked for me unfortunately

jacquesdev avatar Jun 19 '19 15:06 jacquesdev

[email protected] supports AndroidX without modifications.

DylanVann avatar Jul 05 '19 06:07 DylanVann

@DylanVann [email protected] will cause IOS crash when open the project.

yongloon avatar Jul 21 '19 22:07 yongloon

@nyl9488 this lib crashes on ios. I ended up using react-native-web-image instead much better!

micabe avatar Sep 18 '19 14:09 micabe

@micabe @nyl9488 It's working fine on iOS and Android. Please open a new issue including the react-native version and a better description of the error.

immortalx avatar Sep 20 '19 02:09 immortalx

adding this helped me: https://github.com/DylanVann/react-native-fast-image/blob/master/docs/app-glide-module.md

aliberski avatar Oct 21 '19 14:10 aliberski