I am upgrading from RN 0.55.3 to 0.59.8 (manually).
I've got it running well on iOS, but when I run react-native run-android I'm getting the following error:
Task :react-native-contacts:compileDebugJavaWithJavac FAILED
/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
I already tried react-native unlink react-native-contacts && react-native link react-native-contacts
I have also tried rm -rf node_modules && yarn as well as watchman watch-del-all && react-native run-android --reset-cache
Click To Expand
#### `android/build.gradle`:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// jitpack repo is necessary to fetch ucrop dependency
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
google()
jcenter()
}
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:26.1.0"
}
}
#### `android/app/build.gradle`:
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('./keystore/debug.keystore')
storePassword 'android'
}
release {
if (project.hasProperty('MyApp_RELEASE_STORE_FILE')) {
storeFile file(MyApp_RELEASE_STORE_FILE)
storePassword MyApp_RELEASE_STORE_PASSWORD
keyAlias MyApp_RELEASE_KEY_ALIAS
keyPassword MyApp_RELEASE_KEY_PASSWORD
}
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "mx.com.MyApp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy 'react-native-camera', 'general'
versionCode 127
versionName "2.1.27"
ndk {
abiFilters "armeabi-v7a", "x86"
}
vectorDrawables.useSupportLibrary = true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-contacts')
implementation project(':@react-native-community/async-storage')
implementation project(':react-native-svg')
implementation project(':react-native-mixpanel')
implementation project(':react-native-fbsdk')
implementation project(':react-native-webview-android-file-upload')
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation project(':react-native-share')
implementation project(':react-native-localization')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-carrier-info')
implementation project(':react-native-sound')
implementation project(':react-native-version-number')
implementation project(':react-native-device-info')
implementation project(':react-native-default-preference')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation project(':react-native-fs')
implementation 'com.google.android.gms:play-services-base:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation "com.google.firebase:firebase-core:16.0.0"
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation "com.google.firebase:firebase-storage:15.0.2"
implementation project(':react-native-maps')
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation project (':react-native-camera')
implementation "com.android.support:support-v4:26.1.0"
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'com.facebook.fresco:animated-gif:1.9.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
#### `android/settings.gradle`:
rootProject.name = 'MyApp'
include ':react-native-contacts'
project(':react-native-contacts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-contacts/android')
include ':@react-native-community/async-storage'
project(':@react-native-community/async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-mixpanel'
project(':react-native-mixpanel').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mixpanel/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-webview-android-file-upload'
project(':react-native-webview-android-file-upload').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-android-file-upload/android')
include ':react-native-default-preference'
project(':react-native-default-preference').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-default-preference/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-version-number'
project(':react-native-version-number').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-number/android')
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
include ':react-native-localization'
project(':react-native-localization').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localization/android')
include ':react-native-carrier-info'
project(':react-native-carrier-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-carrier-info/android')
include ':react-native-image-crop-picker'
project(':react-native-image-crop-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-sound'
project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app'
#### `MainApplication.java`:
package mx.com.MyApp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.horcrux.svg.SvgPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.kevinejohn.RNMixpanel.RNMixpanel;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.rt2zz.reactnativecontacts.ReactNativeContacts;
import com.rncustomwebview.CustomWebViewPackage;
import com.kevinresol.react_native_default_preference.RNDefaultPreferencePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.apsl.versionnumber.RNVersionNumberPackage;
import cl.json.RNSharePackage;
import com.babisoft.ReactNativeLocalization.ReactNativeLocalizationPackage;
import com.ianlin.RNCarrierInfo.RNCarrierInfoPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.zmxv.RNSound.RNSoundPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import org.reactnative.camera.RNCameraPackage;
import com.rnfs.RNFSPackage;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AsyncStoragePackage(),
new SvgPackage(),
new MapsPackage(),
new RNMixpanel(),
new FBSDKPackage(mCallbackManager),
new ReactNativeContacts(),
new CustomWebViewPackage(),
new RNDefaultPreferencePackage(),
new RNDeviceInfo(),
new RNVersionNumberPackage(),
new RNSharePackage(),
new ReactNativeLocalizationPackage(),
new RNFirebaseAnalyticsPackage(),
new RNCarrierInfoPackage(),
new PickerPackage(),
new RNSoundPackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage(),
new RNFirebaseStoragePackage(),
new RNCameraPackage(),
new RNFSPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="mx.com.MyApp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">
<provider
android:authorities="${applicationId}.fileprovider"
android:name="mx.com.MyApp.UploadFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@android:color/black" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="MyApp chanal" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD0dXBRwVfMjdKr2b_EDzh-tkkzhxPd0Xw"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
</manifest>
Click To Expand
**`react-native info` output:**
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
Memory: 17.64 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.0 - /usr/local/bin/node
Yarn: 1.16.0 - /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.3, 28.0.3
System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-25 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.8 => 0.59.8
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [x] Android
- [ ] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **Are you using `TypeScript`?**
- `N`
this is very odd. I'll look into this.
@morenoh149 Any luck?
haven't looked yet
Anybody with a solution for this error? :(
@owaisbakhtiar haven't looked. What have you tried?
@morenoh149 any fix?
@morenoh149 @ryannewton seems like dependency issues
This is proving an issue for us as well
@morenoh149 This is an active issue. Please look into it. We think its probably related to AndroidX Support from Google for Android Support Libraries
https://developers.google.com/android/guides/releases
We followed the above process and got stuck in the following errors. We think the module needs to be updated to support this.
/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java:7: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:26: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java:237: error: cannot find symbol
@NonNull
^
symbol: class NonNull
location: class ContactsProvider
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:35: error: cannot find symbol
public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
^
symbol: class NonNull
location: class ReactNativeContacts
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:35: error: cannot find symbol
public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
^
symbol: class NonNull
location: class ReactNativeContacts
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:924: error: cannot find symbol
protected static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
^
symbol: class NonNull
location: class ContactsManager
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:925: error: cannot find symbol
@NonNull int[] grantResults) {
^
symbol: class NonNull
location: class ContactsManager
/home/sumant/Desktop/test/OroWealthApple/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:921: error: cannot find symbol
ActivityCompat.requestPermissions(currentActivity, new String[]{PERMISSION_READ_CONTACTS}, PERMISSION_REQUEST_CODE);
^
symbol: variable ActivityCompat
location: class ContactsManager
10 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-contacts:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Please provide support or can there be a temporary work around? Let us know
@ryannewton @morenoh149 @suhanlee l've just fixed this issue. This happens when you enabled androidX. It will work fine if you disable it. Else you need to fix the issues by importing the error packages from androidx instead.
@ManigandanRaamanathan yes thats true. Its due to AndroidX. But how can we disable it.? Our app doesn't run if we disable it. We are in midst of migrating to AndroidX and I guess every other module will need to support it in near time too. Can there be any workaround for this module if you can tell?
@Subway19 I don't know what the fix is. If you figure it out submit a PR and I can merge it.
@morenoh149 @Subway19 @troydaniels @ryannewton this is the fix I've found working.
Note, this fix only works if you have enabled the AndroidX.
Perform the below modifications:
ContactsManager.java
// import android.support.annotation.NonNull; //Remove this
// import android.support.v4.app.ActivityCompat; //Remove this
import androidx.annotation.NonNull; //<- Add this
import androidx.core.app.ActivityCompat; // <- Add this
ContactsProvider.java
// import android.support.annotation.NonNull; //Remove this
import androidx.annotation.NonNull; // <- Add this
ReactNativeContacts.java
// import android.support.annotation.NonNull; //Remove this
import androidx.annotation.NonNull; // <- Add this
These fixes works like a charm.
@ManigandanRaamanathan Awesome. Thanks for this. Seeing the error, I think this will work. But we have now decided not to do AndroidX Migration since many other react-native modules are not ready yet.
@morenoh149 You can incorporate this changes in next version since this will be required anytime soon.
@Subway19 you can create your own script to automate this modifications. Mush simpler. Anyways this will be a troublemaker if you are using firebase libraries. Firebase, recently made some breaking changes.
@ManigandanRaamanathan Yes I am using firebase too. Too much trouble. There is an active discussion happening on this on react-native repo which I am following.
@Subway19 exactly, this firebase breaking changes caused huge issues. But we able to fix it with custom scripts to automate the modifications in modules for the time being until the each modules gets updated
Is there anyway to detect androidX at runtime and conditionally import as you outlined? Will wait to see how other react native modules handle this.
We resolved this eventually by setting in our project's android/build.gradle:
buildscript {
ext {
...
googlePlayServicesVersion = "11.0.4"
...
}
}
Added benefit that it resolves similar issues in other packages.
Hope this helps. Happy coding :D
@troydaniels is that a project-level solution? anyway to do that in a dependency like react-native-contacts?
We resolved this eventually by setting in our project's
android/build.gradle:buildscript { ext { ... googlePlayServicesVersion = "11.0.4" ... } }Added benefit that it resolves similar issues in other packages.
Hope this helps. Happy coding :D
Could you help me understand what this does? I'm still getting the error and want to understand where I should dig further.
Hi there! The whole react-native community will be struggling with the AndroidX transition for a while.
The community came up with a tool called jetifier that offers forwards compatibility from non-AndroidX apps to libraries (like this one) that have implemented AndroidX, by "reverse-jetifying" the source with a call to npx jetify -r so you can use the AndroidX version of the library in your non-AndroidX app, until you migrate.
I've tested it on this module and it appears to work (I use react-native-contacts in my app, I'm not just the jetifier maintainer).
I encourage you to migrate to AndroidX, but until then this can help.
When you do migrate to AndroidX you have the opposite problem with other libraries at which point you'd use jetifier in the forward direction with a call to npx jetify.
Please help spread the word so your fellow developers don't get stuck - app development is hard enough. Cheers!
sounds like we got to run jetify on this project. PRs welcome.
@morenoh149 no! your project is great, it鈥檚 working fine. Your move to AndroidX is the expected action a library should take, I was just posting that up for your library users - to note they can still use the library either way - whether they have converted or not. You should be able to close this and happily consider both your migration done, and your users to be supported before and after they move. jetifier is an app-level tool the users will install, it aligns the libraries with the app鈥檚 androidx migration status
Gotcha.
it is still not working after migrating androidx. @morenoh149
Here's the react native info...
React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i3-2330M CPU @ 2.20GHz
Memory: 398.24 MB / 7.70 GB
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 11.2.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
SDKs:
Android SDK:
API Levels: 17, 23, 27, 28
Build Tools: 27.0.3, 28.0.3
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
I had similar issues when migrating to androidx. this issue comes due to the Old Butter Knife library dependency.
if you are using butter knife then you should use at least butter knife version 9.0.0-SNAPSHOT or above.
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
Most helpful comment
Hi there! The whole react-native community will be struggling with the AndroidX transition for a while.
The community came up with a tool called jetifier that offers forwards compatibility from non-AndroidX apps to libraries (like this one) that have implemented AndroidX, by "reverse-jetifying" the source with a call to
npx jetify -rso you can use the AndroidX version of the library in your non-AndroidX app, until you migrate.I've tested it on this module and it appears to work (I use react-native-contacts in my app, I'm not just the jetifier maintainer).
I encourage you to migrate to AndroidX, but until then this can help.
When you do migrate to AndroidX you have the opposite problem with other libraries at which point you'd use jetifier in the forward direction with a call to
npx jetify.Please help spread the word so your fellow developers don't get stuck - app development is hard enough. Cheers!