NativeScript / NativeScript/android

Implementing native android .aar file or .aidl in Nativescript throws native calss object without access to methods

未关闭
#1,535 4 条评论 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:
  • Android Runtime:
  • iOS Runtime:
  • Plugin(s):
    Android
    Describe the bug

I have an Android SDk done with java whic I already converted to .aar file. I created a plugin and placed the aar file in App_Resources/Android/libs directory. In my index.js file, I have this

var intent = new android.content.Intent(application.android.foregroundActivity, com.iposprinter.printertestdemo.IPosPrinterTestDemo.class)
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
application.android.foregroundActivity.startActivity(intent);

This cause the sdk to display.

Doing this

var iposprinter=new com.iposprinter.printertestdemo.IPosPrinterTestDemo()
console.log(iposprinter) //outputs com.iposprinter.printertestdemo.IPosPrinterTestDemo@682890e
while this `console.log(iposprinter.printerInit) outputs undefined`

while this

`console.log(iposprinter.printerInit) outputs undefined`
console.log(iposprinter.printerInit()) outputs undefined
TypeError: iposprinter.printerInit is not a function


How do I call methods from this package?
To Reproduce

Expected behavior

Sample project

Additional context

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从插件的 index.js 和 App_Resources/Android/libs 下的 .aar 放置位置开始,然后重现 issue 中的 native object 和 printerInit 日志。检查 Android runtime 如何公开已打包的 Java class;当 SDK 方法可用并且能够在不出现 TypeError 的情况下调用时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, java
领域
mobile-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。