R
R
reactreact2015-11-26 14:38:50
Android
reactreact, 2015-11-26 14:38:50

The build is not going, what could be the problem?

React-native: I'm trying to connect the module https://github.com/nucleartux/react-native-date , after doing the 4th step "Step 4 - Register React Package", the application doesn't build, swears at .addPackage(new ReactDatePackage (this)). What could be the problem? My file:

package com.myapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;

import com.facebook.react.LifecycleState;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import me.nucleartux.date.ReactDatePackage;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends Activity implements

DefaultHardwareBackBtnHandler {

private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;

@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 ReactDatePackage(this))
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();

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

    setContentView(mReactRootView);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
        mReactInstanceManager.showDevOptionsDialog();
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

@Override
public void onBackPressed() {
  if (mReactInstanceManager != null) {
    mReactInstanceManager.onBackPressed();
  } else {
    super.onBackPressed();
  }
}

@Override
public void invokeDefaultOnBackPressed() {
  super.onBackPressed();
}

@Override
protected void onPause() {
    super.onPause();

    if (mReactInstanceManager != null) {
        mReactInstanceManager.onPause();
    }
}

@Override
protected void onResume() {
    super.onResume();

    if (mReactInstanceManager != null) {
        mReactInstanceManager.onResume(this);
    }
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Anatolyevich, 2015-11-26
@vitalyraevsky

you need to look at the log and gradle files
----
did not look at the comments
He clearly tells you that he cannot cast MainActivity as FragmentActivity , dig in this direction.
Try replacing extends Activity with extends AppCompatActivity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question