NativeScript / NativeScript/android

Can not extend android.content.ContentProvider

オープン
#1,547 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C++
スター
563
フォーク
144
平均マージ
10時間 46分
マージ済み PR(30日)
14

説明

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:
  • Cross-platform modules: 6.2.0
  • Android Runtime: 6.2.0
  • iOS Runtime (if applicable):
  • Plugin(s):

Describe the bug
When starting app that has android.content.ContentProvider as in the simplest way I could find Android explodes with RuntimeException as below:

Process: org.nativescript.testprovider, PID: 8272
java.lang.RuntimeException: Unable to get provider com.tns.MyProvider: java.lang.NullPointerException: Attempt to read from field 'int com.tns.Runtime.currentObjectId' on a null object reference
	at android.app.ActivityThread.installProvider(ActivityThread.java:6396)
	at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
	at android.app.ActivityThread.access$1100(ActivityThread.java:199)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6669)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to read from field 'int com.tns.Runtime.currentObjectId' on a null object reference
	at com.tns.Runtime.initInstance(Runtime.java:788)
	at com.tns.MyProvider.<init>(MyProvider.java:13)
	at java.lang.Class.newInstance(Native Method)
	at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
	at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:62)
	at android.app.ActivityThread.installProvider(ActivityThread.java:6380)
	... 10 more

To Reproduce
Extend android.content.ContentProvider with any content and try to start the app.

Expected behavior

  • App does not crash
  • Content provider query is being called to get the directory

Sample project
Demo project based on "Plain JavaScript -Hello World" template

Additional context
I managed to have it working using pure Android without problems and I copied the fragments of AndroidManifest.xml from it.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされたnativescript-content-providerデモとそのAndroidManifest.xmlを使ってクラッシュを再現し、ContentProvider拡張とRuntime.initInstanceのスタックトレースから調査を開始します。NativeScriptの動作を、報告者が提示した動作する純粋なAndroidの例と比較します。完了条件は、アプリがクラッシュせずに起動し、ディレクトリを取得するためにContentProviderのクエリが呼び出されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android
領域
mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。