NativeScript / NativeScript/android
Can not extend android.content.ContentProvider
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 563
- Fork
- 144
- Merge trung bình
- 10 giờ 46 phút
- Pull request đã merge (30 ngày)
- 14
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện lỗi crash bằng bản demo nativescript-content-provider được liên kết và AndroidManifest.xml của nó, bắt đầu từ phần mở rộng ContentProvider và stack trace của Runtime.initInstance. So sánh hành vi của NativeScript với ví dụ Android thuần túy đang hoạt động của người báo cáo; hoàn thành có nghĩa là ứng dụng khởi động mà không bị crash và truy vấn ContentProvider được gọi để lấy thư mục.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android
- Lĩnh vực
- mobile-dev
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100