Doesn't compile after jetifier with androidx
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
Same problem here! please do something about this, i dont want to migrate to react-native-camera :(
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
@irondsd did you find a solution to this? I also have this problem.
@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 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.
@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.
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
I had the same Problem but i managed to fix it by doing the following:
- Go to node_modules\react-native-camera-kit\android\src\main\java\com\wix\RNCameraKit\gallery
- Open GalleryView.java
- Replace the 5th Line "import androidx.gridlayout.widget.GridLayoutManager;" with this Line "import androidx.recyclerview.widget.GridLayoutManager;"
@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 Are you sure the import statement is "recyclerview" and not "gridlayout" ?
@darwesh96 yes.
Also, getting this error.
GalleryAdapter.java:7: error: package androidx.recyclerview.widget does not exist
import androidx.recyclerview.widget.RecyclerView;
@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?