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

React Native 0.62.0 Cannot find symbol error (Android) #104

Open
akshaystreak opened this issue Apr 5, 2020 · 4 comments
Open

React Native 0.62.0 Cannot find symbol error (Android) #104

akshaystreak opened this issue Apr 5, 2020 · 4 comments

Comments

@akshaystreak
Copy link

akshaystreak commented Apr 5, 2020

/Users/streakui/streak_crypto_app/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java:10: error: cannot find symbol
import com.facebook.react.modules.core.Timing;
^
symbol: class Timing
location: package com.facebook.react.modules.core
/Users/streakui/streak_crypto_app/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java:40: error: cannot find symbol
new Timing(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),
^
symbol: class Timing
location: class ThreadBaseReactPackage
/Users/streakui/streak_crypto_app/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java:52: error: constructor DevSettingsModule in class DevSettingsModule cannot be applied to given types;
new DevSettingsModule(reactInstanceManager.getDevSupportManager())
^
required: ReactApplicationContext,DevSupportManager
found: DevSupportManager
reason: actual and formal argument lists differ in length
3 errors
3 warnings

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-threads:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

In android while building the app I am facing the above issue.

minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28

react native version = 0.62.0
react version = 16.9.0

@akshaystreak
Copy link
Author

akshaystreak commented Apr 5, 2020

this issue is fixed by changing the following file in the package

In ThreadBaseReactPackage.java file change the following

The first two errors are fixed by changing the timing modal to TimingModule of react.
React has changed the name of file from timing to TimingModule.

From:
import com.facebook.react.modules.core.Timing;
new Timing(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),

To:
import com.facebook.react.modules.core.TimingModule;
new TimingModule(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),

next bug fixed by passing react instance to DevSettingsModule

From:
new DevSettingsModule(reactInstanceManager.getDevSupportManager())

To:
new DevSettingsModule(catalystApplicationContext, reactInstanceManager.getDevSupportManager())

Please fix these things in your module, So that it will not give error for people using RN 0.62.0

@ruankao-mengxin
Copy link

package com.reactlibrary;

import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.devsupport.JSCHeapCapture;
import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.core.ExceptionsManagerModule;
import com.facebook.react.modules.core.Timing;
import com.facebook.react.modules.debug.SourceCodeModule;
import com.facebook.react.modules.intent.IntentModule;
import com.facebook.react.modules.network.NetworkingModule;
import com.facebook.react.modules.storage.AsyncStorageModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.modules.vibration.VibrationModule;
import com.facebook.react.modules.websocket.WebSocketModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.modules.debug.DevSettingsModule;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ThreadBaseReactPackage implements ReactPackage {

private final ReactInstanceManager reactInstanceManager;

public ThreadBaseReactPackage(ReactInstanceManager reactInstanceManager) {
    this.reactInstanceManager = reactInstanceManager;
}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext catalystApplicationContext) {
    return Arrays.<NativeModule>asList(
            // Core list
            new AndroidInfoModule(catalystApplicationContext),
            new ExceptionsManagerModule(reactInstanceManager.getDevSupportManager()),
            new AppStateModule(catalystApplicationContext),
            new Timing(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),
            new UIManagerStubModule(catalystApplicationContext),
            new SourceCodeModule(catalystApplicationContext),
            new JSCHeapCapture(catalystApplicationContext),

            // Main list
            new AsyncStorageModule(catalystApplicationContext),
            new IntentModule(catalystApplicationContext),
            new NetworkingModule(catalystApplicationContext),
            new VibrationModule(catalystApplicationContext),
            new WebSocketModule(catalystApplicationContext),
            new ThreadSelfModule(catalystApplicationContext),
            new DevSettingsModule(reactInstanceManager.getDevSupportManager())
    );
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return new ArrayList<>(0);
}

}

@linehammer
Copy link

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the "symbol" means.

The general causes for a Cannot find symbol error are things like:

  • Incorrect spelling.
  • Wrong case. Halo is different from halo.
  • Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
  • No variable declaration or variable is outside of the scope you are referencing it in.

@railsjack
Copy link

@linehammer
I think that you didn't read the way of fixing the problems above.
He mentioned the missing of TimingModule and DevSettings.
So, I think that this should be done by the module developer (on the native side).

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

4 participants