我通过命令
在android模拟器中启动应用程序后构建react-native appreact-native run-android
我看到应用程序在模拟器中打开并且工作正常但在关闭应用程序后我没有在模拟器中看到图标,甚至在搜索时我都找不到它。
android文件夹中的配置: MainApplication.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中运行它时会保存图标,我在关闭应用程序后会看到它。
答案 0 :(得分:1)
如果希望它出现在模拟器中,则需要从IDE运行它,而不是命令行。进入Android Studio,选择您的设备并单击运行。它应该出现。
以下是有关Android模拟器https://developer.android.com/studio/run/emulator.html?gclid=EAIaIQobChMIxOTmjKHQ1wIV7pPtCh1Rdw7REAAYASAAEgJmTPD_BwE
的一些额外信息