Javascript 在REACT-NATIVE的MainActivity.java中找不到方法getPackages()
我正在构建一个音乐播放器,我需要获取歌曲的元数据,为此,我使用以下软件包:Javascript 在REACT-NATIVE的MainActivity.java中找不到方法getPackages(),javascript,react-native,android-studio,Javascript,React Native,Android Studio,我正在构建一个音乐播放器,我需要获取歌曲的元数据,为此,我使用以下软件包: react native get music files,按照安装说明进行安装: 它说添加到getPackages()方法返回的列表中,但我认为我的android studio版本不同,我没有,所以不知道放在哪里: 这是我的主要活动: package com.musicplayer; import com.reactlibrary.RNReatNativeGetMusicFilesPackage; import an
react native get music files
,按照安装说明进行安装:
它说添加到getPackages()
方法返回的列表中,但我认为我的android studio版本不同,我没有,所以不知道放在哪里:
这是我的主要活动:
package com.musicplayer;
import com.reactlibrary.RNReatNativeGetMusicFilesPackage;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import expo.modules.splashscreen.singletons.SplashScreen;
import expo.modules.splashscreen.SplashScreenImageResizeMode;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// SplashScreen.show(...) has to be called after super.onCreate(...)
// Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "main";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
我在安装时遇到了类似的问题 我发现有人告诉我这在RN+29中发生了变化。现在,
getPackages()
可以在android/app/main/java/[…]/MainApplication.java
中找到
然而,当我在那里添加它时,我得到一个错误,说这个包被添加了两次。运行react native run android
后,这似乎在/android/app/build/generated/[…]/PackageList.java
中得到了解决。我只是没有添加它,现在它为我工作