question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[android] cannot find symbol import com.facebook.react.uimanager.UIBlock

See original GitHub issue

Hello there,

I’m struggling to run the android app. First the app was building but instantly crashing on my device, then I’ve updated react-native to the latest stable realease, now though the app is not building throwing the following error:

Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :react-native-fbads
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-google-analytics-bridge
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-sound
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Download https://jcenter.bintray.com/com/google/ads/mediation/facebook/maven-metadata.xml
Download https://jcenter.bintray.com/com/google/ads/mediation/facebook/4.99.3.0/facebook-4.99.3.0.pom
Download https://jcenter.bintray.com/com/google/ads/mediation/facebook/4.99.3.0/facebook-4.99.3.0.aar

> Task :react-native-fbads:compileDebugJavaWithJavac FAILED
${projectDir}/node_modules/react-native-fbads/android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdManager.java:21: error: cannot find symbol
import com.facebook.react.uimanager.UIBlock;
                                   ^
  symbol:   class UIBlock
  location: package com.facebook.react.uimanager
${projectDir}/node_modules/react-native-fbads/android/app/src/main/java/suraj/tiwari/reactnativefbads/NativeAdManager.java:145: error: cannot find symbol
    getReactApplicationContext().getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
                                                                                       ^
  symbol:   class UIBlock
  location: class NativeAdManager
${projectDir}/node_modules/react-native-fbads/android/app/src/main/java/suraj/tiwari/reactnativefbads/FBAdsPackage.java:26: error: method asList in class Arrays cannot be applied to given types;
        return Arrays.<NativeModule>asList(
                     ^
  required: T[]
  found: NativeAdManager,AdSettingsManager,InterstitialAdManager,NativeAdChoicesViewManager
  reason: varargs mismatch; NativeAdChoicesViewManager cannot be converted to NativeModule
  where T is a type-variable:
    T extends Object declared in method <T>asList(T...)
Note: ${projectDir}/node_modules/react-native-fbads/android/app/src/main/java/suraj/tiwari/reactnativefbads/BannerViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbads:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
49 actionable tasks: 4 executed, 45 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

My react-native info

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 61.52 MB / 8.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.9.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.2.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        Build Tools: 23.0.1, 26.0.1, 26.0.3, 27.0.1, 27.0.3, 28.0.3
        API Levels: 23, 26, 27, 28
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
      react-native: 0.57.4 => 0.57.4
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Any help would be highly appreciated, as I’m struggling with react-native and ads for a while now. If you need more information please let me know.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
erandagancommented, Oct 28, 2018

Your project level build.gradle is missing the important part. Under allprojects, add

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

Should look like

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

This is the part that tells Gradle to look React Native locally.

FYI, this has nothing to do with this library - please ensure you upgrade RN properly 😃

0reactions
constantin-melniciuccommented, Oct 28, 2018

@erandagan oh damn, I miss-merged that… damn, that was real stupid. Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native error cannot find symbol import com.facebook. ...
Am getting below build error when I hit run-android cannot find symbol import com.facebook.react.uimanager.UIBlock.
Read more >
error: package com.facebook.react.bridge does not exist
How to fix React Native android build issue "package com.facebook.react.bridge does not ... error: cannot find symbol import com.facebook.react.bridge.
Read more >
How to fix this error I get when importing kotlin package ...
import com.facebook.react.uimanager. ... Np! When I add that import back I get the same error I had at first (cannot find symbol for...
Read more >
Android custom native module
See the example below: android/app/src/main/java/com/notetaker/device/DeviceModule.java. package com.notetaker.device; import com.facebook.react.bridge.
Read more >
Different Ways to fix Cannot resolve symbol ...
gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile 'com.android.support:appcompat- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found