Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):
return CodePush.getJSBundleFile(); to getJSMainModuleName()I also tried add this but still same problem
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG));
return packages;
}
What you expected to happen?
CodePush can update my code
What actually happens?
Get Error A CodePush instance has not been created yet. Have you added it to your app's list of ReactPackages?
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sting.movie/com.safety.MainActivity}: com.microsoft.codepush.react.CodePushNotInitializedException: A CodePush instance has not been created yet. Have you added it to your app's list of ReactPackages?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3268)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3407)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7343)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)
Caused by: com.microsoft.codepush.react.CodePushNotInitializedException: A CodePush instance has not been created yet. Have you added it to your app's list of ReactPackages?
at com.microsoft.codepush.react.CodePush.getJSBundleFile(CodePush.java:206)
at com.microsoft.codepush.react.CodePush.getJSBundleFile(CodePush.java:201)
at com.safety.MainApplication$1.getJSMainModuleName(MainApplication.java:35)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:68)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:38)
at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:103)
at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:88)
at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:83)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3243)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3407)聽
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)聽
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)聽
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)聽
at android.os.Handler.dispatchMessage(Handler.java:107)聽
at android.os.Looper.loop(Looper.java:214)聽
at android.app.ActivityThread.main(ActivityThread.java:7343)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)聽
Examples folder run node create-app.js appName [email protected] [email protected] command to generate plain CodePushified React Native app. Please see description on top of create-app.js file content if neededthis line
packages.add(new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG));
does the trick for me
@Stjng were you able to find a solution for this?
@bhavukjain1 Yes, its because i was confuse about getJSMainModuleName and getJSBundleFile in MainApplication.java ( also not read the docs carefully ). Just add both of this function and it should work.
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected String getJSBundleFile() { return CodePush.getJSBundleFile();
}
@Stjng, did the same thing... guess the docs could have a small note on this
import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage;
import com.microsoft.codepush.react.CodePush;
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)));
packages.add(new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)));
packages.add(new AppCenterReactNativePackage(MainApplication.this));
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
error:
com.microsoft.codepush.react.CodePushNotInitializedException: A CodePush instance has not been created yet. Have you added it to your app's list of ReactPackages?
EDIT:
THIS LINE SAVE MY LIFE
packages.add(new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG));
this line
packages.add(new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG));does the trick for me
thank you!!! you saved my day!
Most helpful comment
this line
does the trick for me