[ANDROID] Codegen generate wrong package name

This issue has been created since 2022-11-18.

Description

Hi everyone,
I try to follow this tutorial:
https://reactnative.dev/docs/the-new-architecture/pillars-turbomodules

My RTNCalculator folder follow this tuto:
image

When codegen generate code i get this architecture:

image

I would expect codegen to generate:
-> codegen/java/com/RTNCalculator

After codegen generate code i need to manually move NativeCalculatorSpec.java to
rtn-calculator/android/src/main/java/com/RTNCAlculator

image

I need to do this for my RTNCalculatorModule.java which extend NativeCalculatorSpec

package com.RTNCalculator;

import androidx.annotation.NonNull;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import java.util.Map;
import java.util.HashMap;

public class RTNCalculatorModule extends NativeCalculatorSpec {

    public static String NAME = "RTNCalculator";

    RTNCalculatorModule(ReactApplicationContext context) {
        super(context);
    }

    @Override
    @NonNull
    public String getName() {
        return NAME;
    }

    @Override
    public void add(double a, double b, Promise promise) {
        promise.resolve(a + b);
    }
}

Version

0.70.6

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 12.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 153.64 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.1.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
    Watchman: 2022.11.07.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/eedelin/.rvm/gems/ruby-2.7.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK:
      Android NDK: 22.1.7171670
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8815526
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.6 => 0.70.6 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Create MyApp folder with:
npx react-native init MyApp --template react-native-template-typescript

In gradle.properties of android myApp project change newArchEnabled to true

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.125.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=true

Follow every step of https://reactnative.dev/docs/the-new-architecture/pillars-turbomodules

Run android and NativeCalculatorSpec can't be found from RTNCalculatorModule

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

I push all my files here -> https://github.com/ederwan/turboModule-codegen-error

cortinico wrote this answer on 2022-11-23

I would expect codegen to generate:
-> codegen/java/com/RTNCalculator

As explained in the guide you linked, you can configure the package with the javaPackageName key in the top level package.json inside the codegenConfig.

Screenshot 2022-11-23 at 18 01 01

In your case it should be "com.RTNCalculator" while I believe you have "com.calculator"

More Details About Repo
Owner Name facebook
Repo Name react-native
Full Name facebook/react-native
Language JavaScript
Created Date 2015-01-09
Updated Date 2022-12-10
Star Count 106395
Watcher Count 3660
Fork Count 22685
Issue Count 2288

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Bug: No fallback if click event failed (need double click) 1 2022-06-30 2022-11-04
Feature request - separate scheduling logic to schedule one or more workflows at few given times with different given parameters 0 2022-08-27 2022-10-07
👾 [Bug Report] Incorrect Instance Spawns (TBC) 1 2021-10-18 2022-11-10
what kubernetes version support current? 5 2022-05-26 2022-09-12
References to V2 AWS SDK and an unknown DynamoDBClientV3 4 2022-07-13 2022-11-14
Bot Script Enhancement and Maintaining 2 2021-09-05 2022-08-21
cannot publish CVE v5 record with vendor, product, collectionURL and packageName 0 2022-11-29 2022-11-29
firewalld process is accessing deleted files in tmp folder 6 2021-10-28 2022-12-09
API:s requiring credentials fail 3 2021-11-09 2022-05-27
Gracefully skip nightly releases when credentials aren't present 3 2022-05-10 2022-12-04
Missing Patreon icon in footer 4 2022-05-06 2022-11-21
text field including the reason a resubmitted bot got denied before 0 2022-04-18 2022-11-16
docs: Listed minimum node version not supported 1 2022-09-29 2022-11-13
[ENHANCEMENT] [DEV] Clamav on remote docker/socket 2 2021-06-03 2022-11-01
How to add Radam to fairseq ? 1 2021-05-17 2022-11-26
Question: what's the meaning about below env vars 11 2022-05-17 2022-10-05
im applying for the fifth time this week for the api still not receiving 0 2022-08-24 2022-11-12
長野県上伊那郡南箕輪村のデータについて 3 2021-03-24 2022-01-14
Identifier '_unref' has already been declared 1 2022-09-08 2022-09-20
Features list incorrectly ordered, causing incorrect prediction 0 2022-10-26 2022-11-07
Snowpipe Quickstart Guide - Pipe Ownership Change requires pausing the pipe 0 2022-10-31 2022-11-07
Extreme amouts of Lag 1 2022-07-30 2022-09-01
LibreNMS not working anymore after PHP upgrade from 7.4 to 8.1 1 2022-08-26 2022-09-24
options to configure rook-ceph containers args .. 4 2022-04-14 2022-11-16
"Could not connect to execution endpoint" when run prysm with geth on ropsten 3 2022-06-08 2022-12-04
Taxonomy menu name isn't using the "has_many" value. 3 2020-01-07 2022-12-06
Feature request: showing moved lines differently 2 2021-08-20 2022-12-02
No Matches Found with yarn berry + wildcards 4 2022-03-14 2022-12-03
Do have an approximate time plan for this proposal? 0 2021-05-14 2022-11-26
On some subreddits the app uses a different default sorting 0 2022-11-30 2022-12-06
Upgrade mobile controls. 0 2021-07-20 2022-12-06
Could not found global transaction xid = %s, may be has finished 8 2021-12-16 2022-10-27
[Bug] When not providing a route `model` hook, and not providing a model with a `.find` function, an error occurs 4 2022-02-15 2022-09-22
Deprecation "setting-on-hash" 7 2022-02-16 2022-12-09
Optional chaining not supported by UXP/GRE browsers, causing issues 7 2022-02-11 2022-11-26
Replace KnownRepr TypeRepr instances with TypeReprs in existentials 0 2021-03-22 2022-11-22
"InvalidResponse: invalid status code" error on some websites 1 2021-02-16 2022-11-18
[EN289] Problema con data Matrimonio 2 2021-07-19 2022-12-06
Draining iterator 0 2018-05-23 2022-01-08
nacos 的如何分离部署(注册中心 和 配置中心) 6 2022-04-25 2022-11-26
Ability to Export/Promote an AppRunner Service to a CDK stack 1 2021-06-03 2022-10-07
Get sub-sub-folders using prefix in list_blobs 6 2022-05-19 2022-10-27
Waterfall Links 4 2021-11-20 2022-01-16
2022 Alibaba Summer of Code 7 2022-05-25 2022-12-06
Excessive spacing with chained curly blocks 3 2022-03-15 2022-12-05
Marketplace: Add Yoast upsell to marketing/traffic and /stats 17 2022-04-22 2022-10-21
GSoC 2022 Idea: View Logs in the UI 12 2022-02-21 2022-11-08
Null Pointer Exception when User Defined Type is not found. 1 2021-01-27 2022-07-24
OSS build failing: parse/thrifty.yy:65:13: error: ‘struct apache::thrift::compiler::yy::parser::symbol_type’ has no member named ‘token’ 11 2022-03-31 2022-12-02
libthriftcpp2.so: error: undefined reference to 'apache::thrift::RequestPileBase::onDequeued(apache::thrift::ServerRequest&)' 1 2022-02-25 2022-12-02