我正在React Native 0.59.1上构建一个项目,但是当我添加react native youtube时,当我运行react-native run-android时出现以下错误
任何帮助将不胜感激。
任务:react-native-youtube:compileDebugJavaWithJavac FAILED /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeView.java:6:错误:找不到符号 导入androidx.annotation.Nullable; ^ 符号:类Nullable 位置:包androidx.annotation /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:3:错误:找不到符号 导入androidx.annotation.Nullable; ^ 符号:类Nullable 位置:包androidx.annotation /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeView.java:37:错误:找不到符号 @Nullable ^ 符号:类Nullable 位置:YouTubeView类 /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:48:错误:找不到符号 public void receiveCommand(YouTubeView view,int commandType,@Nullable ReadableArray args){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:76:错误:找不到符号 public @Nullable Map getExportedCustomDirectEventTypeConstants(){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:104:错误:找不到符号 public void setApiKey(YouTubeView视图,@Nullable String param){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:109:错误:找不到符号 public void setPropVideoId(YouTubeView视图,@Nullable String param){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:114:错误:找不到符号 public void setPropVideoIds(YouTubeView视图,@Nullable ReadableArray参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:119:错误:找不到符号 public void setPropPlaylistId(YouTubeView视图,@Nullable String param){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:124:错误:找不到符号 public void setPropPlay(YouTubeView视图,@Nullable布尔参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:129:错误:找不到符号 public void setPropLoop(YouTubeView视图,@Nullable布尔参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:134:错误:找不到符号 public void setPropFullscreen(YouTubeView视图,@Nullable布尔参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:139:错误:找不到符号 public void setPropControls(YouTubeView视图,@Nullable int参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:144:错误:找不到符号 public void setPropShowFullscreenButton(YouTubeView视图,@Nullable布尔参数){ ^ 符号:类Nullable 位置:类YouTubeManager /Users/mattleach/Projects/EzeeTrader/EzeeTrader/node_modules/react-native-youtube/android/src/main/java/com/inprogress/reactnativeyoutube/YouTubeManager.java:149:错误:找不到符号 public void setPropResumePlay(YouTubeView视图,@Nullable布尔参数){ ^ 符号:类Nullable 位置:类YouTubeManager
答案 0 :(得分:0)
您必须按照错误日志所述迁移到anroidx。试试这个。
android / gradle.properties
android.useAndroidX=true
android.enableJetifier=true
答案 1 :(得分:0)
放入
android.useAndroidX=true
android.enableJetifier=true
发送到您的gradle.properties
。
然后安装jetify:
yarn add jetifier --dev
npx jetify
然后在package.json
上将jetify添加到您的postinstall-Script中:
"scripts": {
...
"postinstall": "jetify"
...
}
如果仍有@postinstall条目,则仅在末尾添加&&
。
如果您在安装后仍然有patch-package
的示例:
„patch-package && jetify“
至少,运行yarn install
可以解决问题。
如果您在使用jetify时遇到问题,可以使用jetify -r