Skip to content

Autolinking task from example app fails, after adding codegen config to example app. #825

Open
@jhotadhari

Description

@jhotadhari

Description

Hi,

Android only, I have no idea about iOS

I tried to add a TurboModule to the example app. This TurboModule is only needed for the example app, so I added it to the example app only, not to the library itself. Adding TurboModules and FabricViews to the library worked without problems

For this I added a codegenConfig entry to ./example/package.json, adjusted codegenConfig.name, codegenConfig.android.javaPackageName. And added a ./example/src/NativeExample.ts module. And tried to start the example app, so that codegen can generate some code and I can start to build the module in java/kotlin.

The app didn't start (expected because the java side module didn't implement the methods yet). But the error was with autolinking:
Full error:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/home/jhotadhari/Development/android/test/react-native-mapsforge-vtm-new-arch/example/android/app/build.gradle' line: 54

* What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':react-native-mapsforge-vtm' could not be found in project ':app'.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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 11s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build completed with 2 failures. 1: Task failed with an exception.
-----------
* Where:
Build file '/home/jhotadhari/Development/android/test/react-native-mapsforge-vtm-new-arch/example/android/app/build.gradle' line: 54 * What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':react-native-mapsforge-vtm' could not be found in project ':app'. * 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.
============================================================================== 2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle * 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 11s.

Thats not the problem: The package name is react-native-mapsforge-vtm, and the directory is react-native-mapsforge-vtm-new-arch

That part is super weird:

* Where:
Build file '/home/jhotadhari/Development/android/test/react-native-mapsforge-vtm-new-arch/example/android/app/build.gradle' line: 54 * What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':react-native-mapsforge-vtm' could not be found in project ':app'.

build.gradle' line: 54 is:

autolinkLibrariesWithApp()

I went back in git history to a state were I know its stable. But the example app won't start anymore. Same error.

I tried to delete some generated code: rm yarn.lock; rm -rf node_modules/; rm -rf example/node_modules; rm -rf android/generated; rm -rf example/android/generated rm -rf example/android/.gradle; rm -rf android/.gradle; rm -rf example/android/.idea; yarn cache clean; yarn install

But still. the example app won't start, and the error is the same.

I navigated to another directory and cloned the project from git. But even there, I get the same error when I try to start the example app. This commit should work: https://github.com/jhotadhari/react-native-mapsforge-vtm-new-arch/tree/bd0cdca7cb43409ecba7922cb00b9b0de83ba498

I tried to install react-native-clean-project in the root and in the example. But it doesn't help.

It seems there is something cached outside of the repository, but I just can't find it.

I had the same issue some days ago. After installing https://www.npmjs.com/package/react-native-hardwarekey-event as a dependency for a library.
After searching hours for the source of the error, I started a new project and copied the files over.

  • What kind of caches have to be deleted to start the example app again? from a state where I know it works.
  • Is it actually possible to add TurboModules inside the example app, without adding them to the library itself? (I know that it works with legacy native modules)
  • if yes, how?
  • if not, how to prevent that the example app becomes impossible to start?

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

  "create-react-native-library": {
    "languages": "kotlin-objc",
    "type": "fabric-view",
    "version": "0.49.8"
  },

Link to repro

https://github.com/jhotadhari/react-native-mapsforge-vtm-new-arch

Environment

System:
  OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
  CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  Memory: 6.97 GB / 15.28 GB
  Shell:
    version: 5.8.1
    path: /usr/bin/zsh
Binaries:
  Node:
    version: 22.14.0
    path: ~/.nvm/versions/node/v22.14.0/bin/node
  Yarn:
    version: 3.6.1
    path: ~/.nvm/versions/node/v22.14.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.14.0/bin/npm
  Watchman:
    version: 20240414.112832.0
    path: /usr/local/bin/watchman
SDKs:
  Android SDK:
    API Levels:
      - "31"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-34 | Google APIs Intel x86_64 Atom
      - android-VanillaIceCream | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: AI-243.24978.46.2431.13208083
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.2
    wanted: 0.78.2
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions