我构建了反应原生应用程序,在 android 模拟器中通过命令启动应用程序后
react-native run-android
我看到该应用程序在模拟器中打开并且工作正常,但是关闭应用程序后,我在模拟器中看不到该图标,甚至在搜索时也找不到它。
安卓文件夹中的配置:主应用程序.java
package com.glassify;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import community.revteltech.nfc.NfcManagerPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.AlexanderZaytsev.RNI18n.RNI18nPackage;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
// import facebook sdk
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new RNDeviceInfo(),
new NfcManagerPackage(),
// new FBSDKPackage(),
new FBSDKPackage(mCallbackManager),
new RNI18nPackage(),
new RCTCameraPackage(),
new RNBranchPackage(),
new ReactNativeOneSignalPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
Branch.getAutoInstance(this);
FacebookSdk.sdkInitialize(getApplicationContext());
// If you want to use AppEventsLogger to log events.
AppEventsLogger.activateApp(this);
// SoLoader.init(this, /* native exopackage */ false);
}
}
但是当我在iOS中运行它时,它会保存图标,并在关闭应用程序后看到它。
如果希望它出现在模拟器中,则需要从 IDE 而不是命令行运行它。进入Android Studio,选择您的设备,然后单击运行。然后它应该会出现。
以下是有关安卓模拟器的一些额外信息 https://developer.android.com/studio/run/emulator.html?gclid=EAIaIQobChMIxOTmjKHQ1wIV7pPtCh1Rdw7REAAYASAAEgJmTPD_BwE