Build fails on androidx project
Is this a bug report?
Yes
Have you read the Installation Instructions?
Yes
Environment
System: OS: macOS 10.14.4 CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz Memory: 1.20 GB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 11.14.0 - /usr/local/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.2, 28.0.3 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.6.3 => 16.6.3 react-native: 0.57.8 => 0.57.8 npmGlobalPackages: react-native-cli: 2.0.1
react-native-maps: 0.24.2
Steps to Reproduce
- Install react-native-maps on a non-androidx project
- Migrate project to androidx https://developer.android.com/jetpack/androidx/migrate
- Build project
Expected Behavior
Project should build
Actual Behavior
An complitation error occurs :
> Task :react-native-maps:compileDebugJavaWithJavac FAILED
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:12: error: package android.support.v4.view does not exist
import android.support.v4.view.GestureDetectorCompat;
^
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:13: error: package android.support.v4.view does not exist
import android.support.v4.view.MotionEventCompat;
^
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:71: error: package android.support.v4.content does not exist
import static android.support.v4.content.PermissionChecker.checkSelfPermission;
^
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:71: error: static import only from classes and interfaces
import static android.support.v4.content.PermissionChecker.checkSelfPermission;
^
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:103: error: cannot find symbol
private final GestureDetectorCompat gestureDetector;
^
symbol: class GestureDetectorCompat
location: class AirMapView
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:160: error: cannot find symbol
new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGestureListener() {
^
symbol: class GestureDetectorCompat
location: class AirMapView
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:399: error: cannot find symbol
return checkSelfPermission(getContext(), PERMISSIONS[0]) == PackageManager.PERMISSION_GRANTED ||
^
symbol: method checkSelfPermission(Context,String)
location: class AirMapView
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:400: error: cannot find symbol
checkSelfPermission(getContext(), PERMISSIONS[1]) == PackageManager.PERMISSION_GRANTED;
^
symbol: method checkSelfPermission(Context,String)
location: class AirMapView
/Users/user/Workspace/project/node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:907: error: cannot find symbol
int action = MotionEventCompat.getActionMasked(ev);
^
symbol: variable MotionEventCompat
location: class AirMapView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors
Reproducible Demo
@mikaoelitiana can you try https://github.com/react-native-community/react-native-maps/issues/2835#issuecomment-487839805 ?
@rborn unfortunately, it didn't fix my issue.
+1, we need support for androidx for this package
You can try to run this: https://github.com/mikehardy/jetifier and see how it works for you
Nah, it did not work for me.
@Saad-Bashar would be good if you could add your input here - https://github.com/mikehardy/jetifier/issues/8 - with logs, what's going on, etc 🤗
Yes just did @rborn! Thanks. This whole thing is insane. Even yesterday I was running android without any issue. Now I get this android manifest error all on a sudden in a lot of packages.
@Saad-Bashar check this, maybe it helps https://github.com/facebook/react-native/issues/25293#issuecomment-503045776
Getting same error. Is there a workaround?
You can try to run this: https://github.com/mikehardy/jetifier and see how it works for you
This worked for me, but only after I went into the node modules/react-native-map/lib/android/build.gradle and changed
dependencies {
compileOnly('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
...
}
to
dependencies {
implementation('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
...
}
This seems like a fix that should be included in the next PR ASAP
https://github.com/react-native-community/react-native-maps/issues/2839#issuecomment-503678875
Does not work for me
Works for me. Now my app compiles but it is crashing on startup with error:
E/AndroidRuntime: FATAL EXCEPTION: create_react_context
I don't know if it is related to maps or other library.
I did android studio migration and then it worked for me
Will there be a new version of this package that supports androidx?
I am having the same issue
EDIT I got it working by using jetifier
Same as @mursang I'm getting: E/AndroidRuntime: FATAL EXCEPTION: create_react_context
after setting up jetify which fixed all the other modules I was using that are not yet androidx ready.
With the looming August 1st deadline for 64bit builds in play store this should be addressed urgently. I'm trying to get up to RN 0.59.0 to get 64 bit but I'm also having to do androidx to get there. I also assume this means this module is broken on new apps using current RN version(or >0.59.0).
On second look I think my fatal is caused by react-native-device-info and jetify at least got my app building. Will report back on whether maps works at runtime once I overcome this fatal error.
https://gist.github.com/jameslporter/54f711ccfada44c559764f43a4976065
Hey @mursang are you using device-info too? Does your error blame maps?
hey @jameslporter thanks for those tips. I managed to compile without errors by making a fork from this library and migrating imports to the new androidx syntax. After that I still had some issues, but they were caused by other libraries. I needed to update them to the latest version praying that they had androidx support. But after upgrading everything and being able to compile for android, I have issues compiling for iOS. I think I need to wait for every library to properly upgrade versions and match React Native version..
hi, @mikaoelitiana change android.supprot.v* to androidx import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.GestureDetectorCompat; …… import static android.support.v4.content.PermissionChecker.checkSelfPermission;
==>
import androidx.core.view.GestureDetectorCompat; import androidx.core.view.MotionEventCompat; …… import static androidx.core.content.PermissionChecker.checkSelfPermission;
thanks @yangkf1985 update on AirmapView.java import android.support.v4.view.GestureDetectorCompat; --> import androidx.core.view.GestureDetectorCompat; import android.support.v4.view.MotionEventCompat; --> import androidx.core.view.MotionEventCompat;
import static android.support.v4.content.PermissionChecker.checkSelfPermission; --> import static androidx.core.content.PermissionChecker.checkSelfPermission;