react-native-camera-kit icon indicating copy to clipboard operation
react-native-camera-kit copied to clipboard

Doesn't compile after jetifier with androidx

Open irondsd opened this issue 7 years ago • 12 comments

Issue Description

Doesn't compile after jetifier with androidx. I have an app that uses the library, and I just migrated to androidx. I used jetifier on it, and everything except react-native-camera-kit worked perfectly. So my app compiles without camera-kit, but it doesn't with it.

Task :rncamerakit:compileDebugJavaWithJavac FAILED /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:5: error: package and roidx.gridlayout.widget does not exist import androidx.gridlayout.widget.GridLayoutManager; ^ /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:12: error: cannot fin d symbol private class GridLayoutViewManagerWrapper extends GridLayoutManager { ^ symbol: class GridLayoutManager location: class GalleryView /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:18: error: method does not override or implement a method from a supertype @Override ^ /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:21: error: cannot find symbol super.onLayoutChildren(recycler, state); ^ symbol: method onLayoutChildren(RecyclerView.Recycler,State) /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:60: error: incompatible types: LayoutManager cannot be converted to GalleryView.GridLayoutViewManagerWrapper if (getLayoutManager() == null || ((GridLayoutViewManagerWrapper) getLayoutManager()).getSpanCount() != columnCount) { ^ /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:61: error: cannot find symbol GridLayoutManager layoutManager = new GridLayoutViewManagerWrapper(getContext(), columnCount); ^ symbol: class GridLayoutManager location: class GalleryView /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java:62: error: cannot find symbol layoutManager.setOrientation(GridLayoutManager.VERTICAL); ^ symbol: variable GridLayoutManager location: class GalleryView Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/irondsd/dev/neet/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryViewManager.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 7 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':rncamerakit:compileDebugJavaWithJavac'.

Steps to Reproduce / Code Snippets / Screenshots

react-native init test npm install react-native-camera-kit --save android_installation_process npm install --save-dev jetifier npx jetify

add 2 lines to gradle.properties: android.useAndroidX=true android.enableJetifier=true

and then build.gradle: compileSdkVersion 28 buildToolsVersion '28.0.3'

npx react-native run-android doesn't compile anymore

Environment

  • React Native Navigation version: 3.4.1
  • React Native version: 0.59.2
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Both

irondsd avatar Jun 21 '19 11:06 irondsd

Same problem here! please do something about this, i dont want to migrate to react-native-camera :(

paincher avatar Jun 21 '19 21:06 paincher

I think jetifier failed to convert properly android.support.v7.widget.GridLayoutManager to its proper AndroidX counterpart. What I did is I go to node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/gallery/GalleryView.java and I replaced line 5 with import androidx.recyclerview.widget.GridLayoutManager

destorelentejr avatar Jun 27 '19 10:06 destorelentejr

@irondsd did you find a solution to this? I also have this problem.

ledbetterljoshua avatar Jul 01 '19 20:07 ledbetterljoshua

@irondsd did you find a solution to this? I also have this problem.

No. I gave up and I compiled my project without AndroidX.

irondsd avatar Jul 02 '19 13:07 irondsd

@irondsd How exactly did you revert Android Studio to no longer use Android X support. I'm now stuck on this error because I tried to solve for the "fontVariationSettings" not found error.

irajwani avatar Jul 07 '19 05:07 irajwani

@irondsd How exactly did you revert Android Studio to no longer use Android X support. I'm now stuck on this error because I tried to solve for the "fontVariationSettings" not found error.

This is exactly the problem I had. To fix it, I found a way to upgrade to androidx, and tried it. Everything worked except camera-kit. So I temporarily turned off camera functionality for my app. But I wasn't okay with it. So I was looking for another way to fix this issue and finally I found one. It may not work for you though. But try this, just in case.

irondsd avatar Jul 08 '19 14:07 irondsd

I just submitted a PR to jetifier that resolves this issue. Was having a similar problem with react-native-photo-editor that also uses GridLayoutManager

mysport12 avatar Jul 12 '19 21:07 mysport12

I had the same Problem but i managed to fix it by doing the following:

  1. Go to node_modules\react-native-camera-kit\android\src\main\java\com\wix\RNCameraKit\gallery
  2. Open GalleryView.java
  3. Replace the 5th Line "import androidx.gridlayout.widget.GridLayoutManager;" with this Line "import androidx.recyclerview.widget.GridLayoutManager;"

darwesh96 avatar Jul 14 '19 12:07 darwesh96

@darwesh96 I already have import androidx.recyclerview.widget.GridLayoutManager in GalleryView.java and I still am running into this issue. Any other fix you know of?

meldsz avatar Jul 17 '19 11:07 meldsz

@meldsz Are you sure the import statement is "recyclerview" and not "gridlayout" ?

darwesh96 avatar Jul 17 '19 11:07 darwesh96

@darwesh96 yes. Also, getting this error. GalleryAdapter.java:7: error: package androidx.recyclerview.widget does not exist import androidx.recyclerview.widget.RecyclerView;

meldsz avatar Jul 17 '19 13:07 meldsz

@meldsz I am stuck with the same error as you despite already having import androidx.recyclerview.widget.GridLayoutManager in GalleryView.java. Have you found a solution?

HazemMhiri avatar Jul 23 '19 17:07 HazemMhiri