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.

Build from source error: Cannot access 'serviceOf': it is internal in 'org.gradle.configurationcache.extensions'

See original GitHub issue

Description

I’ve been following the Building from source guide and I can’t get packages/react-native-gradle-plugin’s build to work

The only errors I have when building through Android Studio are:

e: /Users/avishay/project/node_modules/react-native/packages/react-native-gradle-plugin/build.gradle.kts:9:49: Cannot access 'serviceOf': it is internal in 'org.gradle.configurationcache.extensions'
e: /Users/avishay/project/node_modules/react-native/packages/react-native-gradle-plugin/build.gradle.kts:41:7: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
internal inline fun <reified T : Any> TaskInternal.serviceOf(): TypeVariable(T) defined in org.gradle.configurationcache.extensions

I couldn’t find any documentation on the configurationcache plugin and I’m pretty inept with Gradle in general.

Version

0.66.4

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 199.65 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - /usr/local/bin/node
    Yarn: 1.22.1 - /usr/local/bin/yarn
    npm: 8.3.0 - ~/Projects/knox/knock/node_modules/.bin/npm
    Watchman: 2021.11.01.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7583922
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.10 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.66.4 => 1000.0.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Follow instructions from this guide https://github.com/facebook/react-native/wiki/Building-from-source
  2. Build the project

Snack, code example, screenshot, or link to a repository

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
pjc0247commented, Apr 4, 2022

I was able to solve this by modifying android/gradle/wrapper/gradle-wrapper.properties

-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
1reaction
Avishayycommented, Jan 10, 2022

Thanks for giving it a try @Avishayy

The only errors I have when building through Android Studio are:

Can you share your project? If not, can you share what’s the content of your android/gradle/wrapper/gradle-wrapper.properties file? It might be that you’re on an older version of Gradle and you can’t build from source as the version from source is newer. I can’t, sorry. My version is 6.1.1 but Android Studio prompted me to update to update to 6.7.1 to make it work

I tried adding kotlin-gradle-plugin, kotlin-android-extensions and kotlin-stdlib-jdk7 dependencies to my project but to no avail.

Ideally you should not have to deal with this at all.

Actually, I don’t want to proceed with this issue anymore as my goal was to get debugging to work. After failing to get building to work, I tried to make a minimal reproducer with rn-tester, which failed too.

Eventually, I found out I can just remove the class I want to debug from the .aar and the java implementation to my project with the same package name, which did work. (BTW, I’m really deep in the debugging hell, I understand the symptoms of my original issue and not why it differs from the previous version, I’ll update soon)

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
i'm trying to make de build of my app, i kwon there are some questions relative abuot this, but no one works for...
Read more >
Configuration cache - Gradle User Manual
The build cache takes care of caching the outputs and intermediate files of the build, such as task outputs or artifact transform outputs....
Read more >
Upgrading your build from Gradle 6.x to the latest
While the following error initially looks like a compile error, it is actually due ... on object of type org.gradle.api.internal.artifacts.dsl.dependencies.
Read more >
Upgrading your build from Gradle 7.x to the latest
Some plugins will break with this new version of Gradle, for example because they use internal APIs that have been removed or changed....
Read more >
Improve the Performance of Gradle Builds
Inspect your build; Update versions; Enable parallel execution; Re-enable the Gradle Daemon; Enable the configuration cache; Enable incremental build for ...
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