Giter Site home page Giter Site logo

Comments (10)

7hens avatar 7hens commented on May 11, 2024

谢谢反馈!

引起这个问题的原因应该是 Android 版本导致的。在 Android 11 (API 30) 后,谷歌对 APP 包的可见性做了限制,可以参考:Android - 管理软件包可见性

解决方法:修改客户端的 AndroidManifest.xml,添加 <queries> 标签,加入服务端的包名。

我已经上述操作提交到了仓库,你重新拉取一下即可。

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

感谢,已经解决这个问题了。另外有2个新的疑问:1.服务端的AIDL文件IMyAidlInterface是不是没起任何作用?2.后续有考虑加入linkToDeath机制吗?

from okbinder.

7hens avatar 7hens commented on May 11, 2024
  1. 这里的 IMyAidlInterface.aidl 是多余的,是当初为了方便对照 AIDL 生成的代码和 OkBinder 生成的代码而加入的。
  2. linkToDeath 也比较重要,但是与业务有点挂钩(如果加入重启功能的话,需要知道启动的 Service 组件和传入的 Intent 参数),影响了 OkBinder 的功能单一性,应该不需要加入到库里。

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

好的,感谢

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

有一个新的问题,当我把你的DEMO差分成2个工程后,分别在2个工程里新建一样包名的library,然后将你sample library里的IRemoteService和IRemoteServiceImpl分别拷贝进这2个包名一样的library。先启动服务端APP,然后启动客户端APP并点击test remote service按钮,log("testInt", remoteService.testInt(1234));这一行直接报空指针

from okbinder.

7hens avatar 7hens commented on May 11, 2024

上面说的情况我没有复现,可能是我的操作流程跟你的不大一样。
不知道你是否方便贴出你的错误栈,(建议先关闭代码混淆功能)。

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

方便加你QQ交流吗?这里回复效率不太高。。。

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

java.lang.NullPointerException: Expected to unbox a 'int' primitive type but was returned null
at $Proxy3.testInt(Unknown Source)
at com.example.servicedemo.MainActivity.onServiceConnected(MainActivity.java:45)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2132)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2164)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:257)
at android.app.ActivityThread.main(ActivityThread.java:8307)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
1.并没有开启代码混淆 2.另外有个疑问,分离成2个APP后,客户端和服务端建立的library分别存放IRemoteService和IRemoteServiceImpl,2个library是否必须包名一致

from okbinder.

7hens avatar 7hens commented on May 11, 2024

IRemoteService 是服务端和客户端的公用接口,必须保持包名和类名一致。

不好意思,我很久没有用过 QQ 了,所以很早就卸载了。:sweat_smile:
不知道你有没有用过 Github 的 discussion,应该也是可以用的。

from okbinder.

TangStudio avatar TangStudio commented on May 11, 2024

已经在discussion里上传了2个工程的代码,代码量很少,就是你工程的拆分成的2个APP工程

from okbinder.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.