Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme not up to date? #15

Open
natterstefan opened this issue Jan 9, 2018 · 1 comment
Open

Readme not up to date? #15

natterstefan opened this issue Jan 9, 2018 · 1 comment

Comments

@natterstefan
Copy link

natterstefan commented Jan 9, 2018

Hi,

I am not sure, if I am missing something. But, my MainActivity.java file (Android) does not look like the one in your Readme:

This is yours:

import com.robinpowered.react.battery.DeviceBatteryPackage;  // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new DeviceBatteryPackage()) // <------ add this line to yout MainActivity class
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "AndroidRNSample", null);

    setContentView(mReactRootView);
  }

  ......

}

This is mine:

package com.xxxxx;

import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "xxxxxx";
    }
}

When I try to build the app I see errors like:

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
                                  ^
  symbol: class Activity

My questions are:

  • do I really need to add onCreate here and not in the MainApplication.java file instead?
  • does it work with react-native 0.50.3?

Thanks for your help.

@gullsharon
Copy link

Hi,

I've tried using this library in my project, using react-native 0.50.4.
What I ended up doing is using react-native link, which didn't change MainActivity.java, but changed MainApplication.java instead.

Now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants