Kotlin issues (companion object)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
App_Resources/Android/src/main/java にある Kotlin の例と、リンクされている ns-android-kotlin.zip サンプルプロジェクトから始めます。デモアプリを実行し、companion-object のフィールドについてコンソール出力を確認し、動作するフィールドおよびメソッドと比較します。@JvmField と const の値に NativeScript から期待どおりアクセスできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- CLI: 8.6.5
- Cross-platform modules: 8.6.2
- Android Runtime: 8.6.1 (also 8.7.0-alpha.1)
- iOS Runtime (if applicable): -
- Plugin(s): -
Describe the bug
I tried to do some basic stuff with Kotlin stuff inside a NativeScript app (as I have no experience with Kotlin development) and I am experiencing some issues with companion objects.
I added this Kotlin file to App_Resources/Android/src/main/java
// KotlinTest.kt
package com.example
class KotlinTest {
val hello = "Hello from Kotlin!" //working
@JvmField
val instanceTestField : Int = 1234 //working
companion object {
@JvmStatic
fun increment(num: Int): Int { //working
return num + 1
}
@JvmField
val message : String = "Hi!" //not working
const val VERSION = 9 //not working
}
}
And I am trying to access the values like this in the NativeScript app:
const testObject = new com.example.KotlinTest();
console.log(testObject.hello); //working
console.log(testObject.instanceTestField); //working
console.log(com.example.KotlinTest.increment(5)); //working
console.log(com.example.KotlinTest.message); //not working
console.log(com.example.KotlinTest.VERSION); //not working
As far as I can read here about @JvmField annotation and here about const modifier this is valid Kotlin so it also shold work in NativeScript, but I always get undefined for those elements.
To Reproduce
Start the demo app provided below and check the logs in console.
Expected behavior
JvmFields and const values inside companion objects should be accessible in NativeScript.
Sample project
ns-android-kotlin.zip
Additional context
- 主要言語
- C++
- スター
- 563
- フォーク
- 144
- 平均マージ
- 10時間 46分
- マージ済み PR(30日)
- 14
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NativeScript/android のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
NativeScript/android#2039 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NativeScript/android#2024 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
NativeScript/android#2020 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
NativeScript/android#2019 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
NativeScript/android#1986 ·
NativeScript/android の issue をすべて見る
似ている issue
-
[BUG] オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
eunomia-bpf/llvmbpf#51 · コメント 1 件 ·
-
status:needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PX4/PX4-Autopilot#28776 ·
-
Website Doc Typo オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
autowarefoundation/autoware_universe#13413 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100