Unable to get the library working | ReactYouTube does not exist | Missing import
See original GitHub issueReact : 16.3.0-alpha.1
React Native : 0.54.0
React Native Youtube : 1.1.0
Support Library : 27.1.0
Install instructions
yarn add react-native-youtube
react-native link
or if you want to be specific react-native link react-native-youtube
Goto android
folder and open the settings.gradle
file
Make sure you have the following lines before include ':app'
include ':react-native-youtube'
project(':react-native-youtube').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-youtube/android')
Then goto android/app
folder and check the build.gradle
file.
You should have a piece of code that looks like this
dependencies { ...... }
Make sure you have implementation project(':react-native-youtube')
within the dependencies
braces.
If you are using an older version of the support library then replace implementation with compile.
Next you need to goto MainApplication.java
which you will find under android/app/src/main/java/com/project_name/MainApplication.java
.
Once there make sure you have import com.inprogress.reactnativeyoutube.ReactNativeYouTube;
as an import.
You will also have a piece of code that looks similar to this along with any other dependency that you may have installed.
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage()
);
}
Add new ReactNativeYouTube()
to it so it looks like this
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new ReactNativeYouTube()
);
}
At this point you should sync gradle and try running the app.
It helps with debugging if you have android studio installed, make sure the import is detected and make sure the react native youtube module gets created after syncing gradle.
I created this not as an issue as i managed to get it working but to help others who have a similar problem, the author failed to mention the line implementation project(':react-native-youtube')
which was missing for me even after linking which I had to manually add. I was able to successfully use the library by following the steps in the above order using the latest react and react native version as mentioned above.
I haven’t checked out the iOS version yet.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:18
- Comments:9 (1 by maintainers)
Top GitHub Comments
The issue comes with Android Studio 3.0. You can find the exact issue I’m talking about for another library at this link
The way I was able to resolve it is by adding
matchingFallbacks = ['debug']
to all the custom build types.Thank you. Vietnamese