mikehardy/jetifier

error: package android.support.annotation does not exist import android.support.annotation.*;

rezasazesh opened this issue · 1 comments

Thank you so much for this package! When I run this package in my project I get all these errors below and I am not sure what to do, has anyone encountered similar issues when migrating to AndroidX?

> Task :react-native-navigation:compileReactNative57_5DebugJavaWithJavac FAILED
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/AttachMode.java:3: error: package android.support.annotation does not exist
import android.support.annotation.*;
^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java:5: error: package android.support.annotation does not exist
import android.support.annotation.*;
^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java:6: error: package android.support.v4.content does not exist
import android.support.v4.content.*;
^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:4: error: package android.support.annotation does not exist
import android.support.annotation.*;
^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:5: error: package android.support.v4.widget does not exist
import android.support.v4.widget.*;
^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:8: error: cannot find symbol
public class SideMenu extends DrawerLayout {
                              ^
  symbol: class DrawerLayout
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/AttachMode.java:54: error: cannot find symbol
    @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
     ^
  symbol:   class VisibleForTesting
  location: class AttachMode
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:9: error: cannot find symbol
    public SideMenu(@NonNull Context context) {
                     ^
  symbol:   class NonNull
  location: class SideMenu
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java:33: error: cannot find symbol
        defaultSelectedTextColor = defaultOptions.bottomTabOptions.selectedIconColor.get(ContextCompat.getColor(context, com.aurelhubert.ahbottomnavigation.R.color.colorBottomNavigationAccent));
                                                                                         ^
  symbol:   variable ContextCompat
  location: class BottomTabPresenter
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java:34: error: cannot find symbol
        defaultTextColor = defaultOptions.bottomTabOptions.iconColor.get(ContextCompat.getColor(context, com.aurelhubert.ahbottomnavigation.R.color.colorBottomNavigationInactive));
                                                                         ^
  symbol:   variable ContextCompat
  location: class BottomTabPresenter
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java:75: error: cannot find symbol
                public void onComplete(@NonNull Drawable drawable) {
                                        ^
  symbol: class NonNull
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java:53: error: incompatible types: SideMenu cannot be converted to DrawerLayout
        DrawerLayout sideMenu = new SideMenu(getActivity());
                                ^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:13: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java:16: error: cannot find symbol
            super.openDrawer(gravity, animate);
            ^
  symbol:   variable super
  location: class SideMenu
Note: /Users/rezasazesh/Desktop/ReactNativeProjects/EPLInternational/node_modules/react-native-navigation/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/react/SyncUiImplementation.java uses or overrides 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.
14 errors

FAILURE: Build failed with an exception.


dependencies {
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-push-notification')
    implementation project(':react-native-firebase')
    implementation project(':react-native-svg')
    implementation project(':react-native-vector-icons')
    implementation project(':@react-native-community_netinfo')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.android.support:design:25.4.0'
    implementation project(':react-native-navigation')
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation "com.google.firebase:firebase-messaging:17.5.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar' // <-- Add this line if you wish to use badge on Android
    //compile project(':react-native-code-push')
}

gradle.properties

android.useAndroidX=true
android.enableJetifier=true

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 19
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    ...
}
"react-native": "0.59.5",
"react-native-code-push": "^5.6.0",
"react-native-elements": "^1.1.0",
"react-native-email": "^1.0.2",
"react-native-firebase": "^5.3.1",
"react-native-global-props": "^1.1.5",
"react-native-navigation": "^2.18.4",
"react-native-push-notification": "^3.1.3",
"react-native-splash-screen": "^3.2.0",
"react-native-svg": "^9.4.0",
"react-native-vector-icons": "^6.4.2"

I ended up solving it doing this

Sorry for opening and issue it was driving me crazy! lol