React-native-code-push: Can not find ChoreographerCompat, ReactChoreographer in CodePushNativeModule.java

Created on 5 Apr 2017  Â·  19Comments  Â·  Source: microsoft/react-native-code-push

Hello, guys

Description

Upgrade to v2.0.1-beta, show can not find ChoreographerCompat, ReactChoreographer in CodePushNativeModule.java

Now, we reinstall back to 1.17.3-beta, it's work.

Additional Information

  • react-native-code-push version: v2.0.1-beta
  • react-native version: 0.42.3
  • iOS/Android/Windows version: Android 5.0
  • Does this reproduce on a debug build or release build? both
  • Does this reproduce on a simulator, or only on a physical device? both

(The more info the faster we will be able to address it!)

img

img

All 19 comments

Same problem.

Hello @Kennytian, @Lxxyx, thank you for reaching us. [email protected] has no backwards compatibility with RN0.42 due to braking changes that has been made in RN0.43, I've updated compatibility table to make it more clear.
Please let me know if you have any questions.

@sergey-akhalkov Thanks for your informations!

To clarify for future use, any increment in the major version (from 1.x.x to 2.x.x, or from 2.x.x to 3.x.x) is a large change and should be done in consultation with our release notes. We've updated our release notes to note this breaking change, apologies for not noting this earlier!

I got same problems. Here is my dependencies

"react": "16.0.0-alpha.6",
"react-native": "0.43.0",
"react-native-code-push": "^2.0.3-beta",
"react-native-sqlite-storage": "^3.3.1"

default

Hi @youngcube, thanks for reaching us.
I've tried to reproduce your issue but with no luck.
I've done the following:
1) Created new RN application with RNinit CLI (RN 0.43.0, react 16.0.0-alpha.6)
2) npm install --save [email protected]
3) npm i --save [email protected]
4) react-native link react-native-code-push
5) open project with Android Studio, was able to build it without any exceptions

Could you please confirm that you still see the error when using the steps from above? (or in other words with newly created app)

@max-mironov Thank you for your response!
As you mentioned, I've follow your step with a new Project, and everything is OK. Sad...- -
Since I want to add React Native in a existed native Android Project. I then read all step that I do in my existed native Project and add all new code & grade dependency to a new Project without using react-native link . Everything is just fine again..

As my React Native code doesn't strong depend on RN0.43 version. I've also tried backward to RN0.42 & code-push 1.17.3beta. This time, no " Can not find ChoreographerCompat " error. My Project can complie successfully.But when my App just run into CodePush method ( like CodePush.sync() ). I got these error:

com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'f.default.sync')

I use CodePush in my js file like this:

import CodePush from 'react-native-code-push'
...
componentDidMount(){
        CodePush.sync().then(success =>{
            console.log(success);
        }).catch(error =>{
            console.log(success);
        });
}

I've also tried some syntax like require but no luck.
My js code works fine in my another iOS Native with ReactNative App. It's also RN0.43 with code-push 2.0.3beta. I can also reach CodePush's update.

I'm very sorry for my poor English for I'm not a native English speaker.
Thank you again!

Here is my code in my native Project
MainApplication.java (hidden codepush key)

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile("main.bundle");
        }

        @Override
        public boolean getUseDeveloperSupport() {
            return false;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new CodePush("??", MainApplication.this, false)
            );
        }
    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

ReactNativeManager.java

public class ReactNativeManager extends Activity implements DefaultHardwareBackBtnHandler {
    private ReactRootView mReactRootView;
    private ReactInstanceManager mReactInstanceManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("main.bundle")
                .setJSMainModuleName("ReactNativeManager")
                .addPackage(new MainReactPackage())
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "ReactNativeManager", null);
        setContentView(mReactRootView);
    }

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

    @Override
    protected void onResume() {
        super.onResume();
        if (mReactInstanceManager != null) {
            mReactInstanceManager.onHostResume(this, this);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (mReactInstanceManager != null) {
            mReactInstanceManager.onHostPause();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mReactInstanceManager != null) {
            mReactInstanceManager.onHostDestroy();
        }
    }

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

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

There is another thing:
When I run grade sync.Grade warn me that react-native-code-push's buildToolsVersion is too low.Since my Project is 25.0.0. I've updated codepush.gradle into 25.0.0 then gradle can continue to sync and then success. I don't know whether this could make something wrong.

@youngcube - np, thanks for quick reply.
So do I get it right that you can build your project successfully unless you do react-native-link command?
Can you try to do manual installation (instead of link command) to see if it helps. Also can you try to remove /node_modules folder completely from your project and then do fresh npm install to reinstall dependencies. Please let us know the results.

@max-mironov Sorry that I've not mentioned that I've tried to follow this manual installation in my Native Project and a New Created Project.
New Create Project : All works fine.
My Native Project With RN&codepush:

  • RN0.43 & CodePush 2.0.3: Compile Error with Error message like : not find ChoreographerCompat
  • RN0.42 & CodePush 1.17.3: Compile Success. But when I use CodePush.sync() in my Js . I got these error :
com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'f.default.sync')

Thank you for your response!

@youngcube - have you tried to remove node_modules and then do npm i?

@max-mironov Yes. Each time I change package.json's react-native version & code-push version I will delete node_modules and run npm install. But no luck - -.Everything works like I've just mentioned.

@youngcube got it, thanks. Do you have a chance to reach me directly and share with me your project so I can investigate the problem deeper?

@max-mironov Sorry - - I can't share it cause it is a company Project.
I can tell you more about this Project.
It's based on C++ with JNI(I know a little about Java. I'm a iOS Developer). This Project use some armev7 so lib. I wonder if it could make this issue happen ?
Anyway, thank you for your advice. I'll try more way with my Android colleague.

@youngcube - understood, that's ok. I'vent seen such issues before so it's not easy for me to say what's wrong here without looking through the source code. If you got an idea how to reproduce it with some kind of demo app that would be very useful.
Also one more thing - can you please verify that path to react-native points to correct location here:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

And also if it is possible - keep us posted if you have any updates about the issue.

@max-mironov Thank you for remind me !
Now that not find ChoreographerCompat Error dismiss with RN0.43 & CodePush 2.0.3.
But sadly this issue is still alive :

com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'f.default.sync')

This error now occur in bothRN0.43 & CodePush 2.0.3. & RN0.42 & CodePush 1.17.3

@max-mironov Good News.
I've just make a test Project which can reproduce this bug successfully.
Here is the git : https://github.com/youngcube/AwesomeProject
Error is :

com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'f.default.sync')

Thanks!

@youngcube - that's good to hear. Do you mind creating separate issue in this repository, so we can address it and discuss other details there?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

panarasi picture panarasi  Â·  4Comments

SudoPlz picture SudoPlz  Â·  4Comments

EdmundMai picture EdmundMai  Â·  4Comments

vira-khdr picture vira-khdr  Â·  3Comments

chrisjrex picture chrisjrex  Â·  4Comments