react-native-webview: Android Studio cannot find symbol class RNCWebViewPackage

I tried @FaiChou’s fix to comment out RequireAPI, but am still receiving errors building with this package not being found by Android Studio even though it appears to be properly linked and exists within node_modules.

settings.gradle contains: include ':react-native-webview' project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

MainApplication.java contains: import com.reactnativecommunity.webview.RNCWebViewPackage;

npm 6.4.1 react-native 0.57.7 node 10.13.0

am I missing something?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 29 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Totally i think they should add a manual installation in doc’s because sometime link command doesn’t work properly

in build.gradle of react-native-webview, update code.

dependencies {
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.facebook.react:react-native:+'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

i resolve this by adding implementation 'com.android.support:support-annotations:28.0.0' in build.gradle of react-native-webview

Totally i think they should add a manual installation in doc’s because sometime link command doesn’t work properly

Not to mention the doc seems a bit snarky about how you must have forgotten to run link when the same errors happen when link fails 👎

Error is the one described in the issue Cannot resolve symbol RNCWebViewPackage

on import com.reactnativecommunity.webview.RNCWebViewPackage; (MainApplication.java)

This is coming soon guys, sorry about the current state of the repo, I’m trying 😍

@aschenkel add compile project(':react-native-webview') to your app/build.gradle and also add

include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

to your settings.gradle

in build.gradle of react-native-webview, update code.

dependencies {
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.facebook.react:react-native:+'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

This is an okay fix but I think its not acceptable because now every developer needs to add the support-annotations dependency to this projects build.gradle file inside node_modules. Thats a whole lotta of unnecessary copy and paste, especially when you have to delete node_modules and run “npm i” again.

Maybe there should be a note somewhere reminding developers not to forget to add implementation ‘com.android.support:support-annotations:28.0.0’ inside “./node_modules/react-native-webview/build.gradle”

@AE0011 @charliewynn thanks!

compile project(':react-native-webview') was missing in my app/build.gradle

For some reason react-native-link was not doing it, but it was writing correctly on settings.gradle

A manual installation in doc’s would be useful

Should your build.gradle have project(':react-native-webview') in its dependencies?

Great, thank you so much.

Will come back to you soon after using the new version.

On Fri, 18 Jan 2019 at 21:13, Thibault Malbranche notifications@github.com wrote:

🎉 This issue has been resolved in version 3.1.3 🎉

The release is available on:

Your semantic-release https://github.com/semantic-release/semantic-release bot 📦🚀

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/react-native-community/react-native-webview/issues/184#issuecomment-455589833, or mute the thread https://github.com/notifications/unsubscribe-auth/AMllGAXTHV6yf-uB-f-k3jgDijDsC1VZks5vEeuzgaJpZM4Y6vsX .

can you test installing like that and let me know if it’s fixed ?

yarn add react-native-webview@https://github.com/react-native-community/react-native-webview#1f11f10