Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find symbol import androidx.annotation.NonNull; - React-native-svg #1267

Closed
EkaRahadi opened this issue Jan 29, 2020 · 1 comment
Closed

Comments

@EkaRahadi
Copy link

Question

Hello, i have problem with react-native-svg, i have installed react-native-svg and linked it. But when i run react-native run-android. show these errors. Is anyone can help me please ?

$ react-native run-android
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from E:\Mobile Development\ReactNative\LFIX\node_modules\react-native\android

Configure project :react-native-i18n
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Task :app:preBuild UP-TO-DATE
Task :react-native-firebase:preBuild UP-TO-DATE
Task :react-native-firebase:preDebugBuild UP-TO-DATE
Task :react-native-firebase:checkDebugManifest UP-TO-DATE
Task :react-native-firebase:processDebugManifest UP-TO-DATE
Task :react-native-i18n:preBuild UP-TO-DATE
Task :react-native-i18n:preDebugBuild UP-TO-DATE
Task :react-native-i18n:checkDebugManifest UP-TO-DATE
Task :react-native-i18n:processDebugManifest UP-TO-DATE
Task :react-native-svg:preBuild UP-TO-DATE
Task :react-native-svg:preDebugBuild UP-TO-DATE
Task :react-native-svg:checkDebugManifest UP-TO-DATE
Task :react-native-svg:processDebugManifest UP-TO-DATE
Task :react-native-vector-icons:preBuild UP-TO-DATE
Task :react-native-vector-icons:preDebugBuild UP-TO-DATE
Task :react-native-vector-icons:checkDebugManifest UP-TO-DATE
Task :react-native-vector-icons:processDebugManifest UP-TO-DATE
Task :app:preDebugBuild
Task :react-native-firebase:compileDebugAidl NO-SOURCE
Task :react-native-i18n:compileDebugAidl NO-SOURCE
Task :react-native-svg:compileDebugAidl NO-SOURCE
Task :react-native-vector-icons:compileDebugAidl NO-SOURCE
Task :app:compileDebugAidl NO-SOURCE
Task :react-native-firebase:packageDebugRenderscript NO-SOURCE
Task :react-native-i18n:packageDebugRenderscript NO-SOURCE
Task :react-native-svg:packageDebugRenderscript NO-SOURCE
Task :react-native-vector-icons:packageDebugRenderscript NO-SOURCE
Task :app:compileDebugRenderscript NO-SOURCE
Task :app:checkDebugManifest UP-TO-DATE
Task :app:generateDebugBuildConfig UP-TO-DATE
Task :app:bundleDebugJsAndAssets SKIPPED
Task :app:prepareLintJar UP-TO-DATE
Task :app:writeDebugApplicationId UP-TO-DATE

Task :app:processDebugGoogleServices
Parsing json file: E:\Mobile Development\ReactNative\LFIX\android\app\google-services.json

Task :app:generateDebugSources
Task :react-native-firebase:compileDebugRenderscript NO-SOURCE
Task :react-native-firebase:generateDebugBuildConfig UP-TO-DATE
Task :react-native-firebase:generateDebugResValues UP-TO-DATE
Task :react-native-firebase:generateDebugResources UP-TO-DATE
Task :react-native-firebase:packageDebugResources UP-TO-DATE
Task :react-native-firebase:generateDebugRFile UP-TO-DATE
Task :react-native-firebase:prepareLintJar UP-TO-DATE
Task :react-native-firebase:generateDebugSources UP-TO-DATE
Task :react-native-firebase:javaPreCompileDebug UP-TO-DATE
Task :react-native-firebase:compileDebugJavaWithJavac UP-TO-DATE
Task :react-native-firebase:bundleLibCompileDebug UP-TO-DATE
Task :react-native-i18n:compileDebugRenderscript NO-SOURCE
Task :react-native-i18n:generateDebugBuildConfig UP-TO-DATE
Task :react-native-i18n:generateDebugResValues UP-TO-DATE
Task :react-native-i18n:generateDebugResources UP-TO-DATE
Task :react-native-i18n:packageDebugResources UP-TO-DATE
Task :react-native-i18n:generateDebugRFile UP-TO-DATE
Task :react-native-i18n:prepareLintJar UP-TO-DATE
Task :react-native-i18n:generateDebugSources UP-TO-DATE
Task :react-native-i18n:javaPreCompileDebug UP-TO-DATE
Task :react-native-i18n:compileDebugJavaWithJavac UP-TO-DATE
Task :react-native-i18n:bundleLibCompileDebug UP-TO-DATE
Task :react-native-svg:compileDebugRenderscript NO-SOURCE
Task :react-native-svg:generateDebugBuildConfig UP-TO-DATE
Task :react-native-svg:generateDebugResValues UP-TO-DATE
Task :react-native-svg:generateDebugResources UP-TO-DATE
Task :react-native-svg:packageDebugResources UP-TO-DATE
Task :react-native-svg:generateDebugRFile UP-TO-DATE
Task :react-native-svg:prepareLintJar UP-TO-DATE
Task :react-native-svg:generateDebugSources UP-TO-DATE
Task :react-native-svg:javaPreCompileDebug UP-TO-DATE

Task :react-native-svg:compileDebugJavaWithJavac FAILED
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\SvgView.java:24: error: cannot find symbol
import androidx.annotation.NonNull;
^
symbol: class NonNull
location: package androidx.annotation
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\ForeignObjectView.java:17: error: cannot find symbol
import androidx.annotation.NonNull;
^
symbol: class NonNull
location: package androidx.annotation
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\SvgView.java:113: error: cannot find symbol
public void onDescendantInvalidated(@nonnull View child, @nonnull View target) {
^
symbol: class NonNull
location: class SvgView
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\SvgView.java:113: error: cannot find symbol
public void onDescendantInvalidated(@nonnull View child, @nonnull View target) {
^
symbol: class NonNull
location: class SvgView
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\ForeignObjectView.java:47: error: cannot find symbol
public void onDescendantInvalidated(@nonnull View child, @nonnull View target) {
^
symbol: class NonNull
location: class ForeignObjectView
E:\Mobile Development\ReactNative\LFIX\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\ForeignObjectView.java:47: error: cannot find symbol
public void onDescendantInvalidated(@nonnull View child, @nonnull View target) {
^
symbol: class NonNull
location: class ForeignObjectView
6 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-svg:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
37 actionable tasks: 3 executed, 34 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

@EkaRahadi
Copy link
Author

Solved. I Add

android.useAndroidX=true
android.enableJetifier=true

in android/gradle.properties

And executed

npm install --save-dev jetifier
npx jetify
npx react-native run-android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant