Describe the bug
The Android template generates an invalid Kotlin file for $$androidCxxLibName$$Package.kt.
The file has a .kt extension but mixes Java and Kotlin syntax, causing the generated project to fail compilation.
To Reproduce
- Generate a new Nitro module using
create-nitro-module.
- Build the Android project.
- The generated
$$androidCxxLibName$$Package.kt fails to compile.
Generated code:
package com.$$androidNamespace$$;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.BaseReactPackage;
import com.margelo.nitro.$$androidNamespace$$.$$androidCxxLibName$$OnLoad;
public class $$androidCxxLibName$$Package : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
ReactModuleInfoProvider { emptyMap() }
companion object {
init {
$$androidCxxLibName$$OnLoad.initializeNative();
}
}
}
Expected behavior
The template should generate valid Kotlin.
For example:
package com.$$androidNamespace$$
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.margelo.nitro.$$androidNamespace$$.$$androidCxxLibName$$OnLoad
class $$androidCxxLibName$$Package : BaseReactPackage() {
override fun getModule(
name: String,
reactContext: ReactApplicationContext,
): NativeModule? = null
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
ReactModuleInfoProvider { emptyMap() }
companion object {
init {
$$androidCxxLibName$$OnLoad.initializeNative()
}
}
}
Additional context
The generated template appears to mix Java and Kotlin syntax:
public class is Java syntax and is invalid in Kotlin.
- The file is emitted with a
.kt extension.
- Semicolons are acceptable in Kotlin, but the class declaration is not.
This looks like a template generation issue rather than a Kotlin compiler issue.
Describe the bug
The Android template generates an invalid Kotlin file for
$$androidCxxLibName$$Package.kt.The file has a
.ktextension but mixes Java and Kotlin syntax, causing the generated project to fail compilation.To Reproduce
create-nitro-module.$$androidCxxLibName$$Package.ktfails to compile.Generated code:
Expected behavior
The template should generate valid Kotlin.
For example:
Additional context
The generated template appears to mix Java and Kotlin syntax:
public classis Java syntax and is invalid in Kotlin..ktextension.This looks like a template generation issue rather than a Kotlin compiler issue.