NativeScript / NativeScript/android

Can not extend android.content.ContentProvider

未关闭
#1,547 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C++
星标
563
派生
144
平均合并
10 小时 46 分钟
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 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 摘要。