android - Gomobile库使用隐藏的API方法

标签 android go android-ndk aar gomobile

我有一个 Android 应用程序,它使用 Golang 库 (.aar),该库由 Gomobile 创建。每当应用程序尝试从库中创建类的实例或调用库方法时,它都会崩溃并显示下一条日志消息:

W/om.example.cal: Accessing hidden method Landroid/app/AppGlobals;->getInitialApplication()Landroid/app/Application; (greylist, reflection, allowed)
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 11110 (om.example.calc), pid 11075 (om.example.calc)
Application terminated.

getInitialApplication 方法位于 Google's light greylist (line 349) . 我知道在 SDK 版本 28 及更高版本上无法访问任何隐藏方法,这就是为什么我在 build.gradle 中编写了下一个(26 是 Play Market 的最低版本) :

compileSdkVersion 26
minSdkVersion 15
targetSdkVersion 26
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.android.support:appcompat-v7:26.1.0'

但这并没有帮助。如何让它发挥作用? 备注:测试设备是在 Ubuntu 18.04 上模拟的 Nexus S

最佳答案

问题是我在模拟器上调试了我的应用程序。显然,它与 native 库不兼容。在手机上调试就可以了。

关于android - Gomobile库使用隐藏的API方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56247031/

相关文章:

android - Android 4.1.2 上奇怪的 JSON 编码问题

android - 驱动器打不开的pdf

javascript - 如何正确地将 MPEG-DASH list 提供给 Shaka 播放器?

go - 将命名类型分配给文字类型值

android - 在 Android Studios C 文件中调用共享库 (.so) 方法

android - 如何使用 valgrind 启动一个安卓应用程序

java - 通过低功耗蓝牙(即通过信标)向附近的移动设备发送通知,且设备上未安装任何应用程序

android - Xamarin:检索项目 CardView 的父级时出错

intellij-idea - 使用 IntelliJ 进行项目设置

Android NDK clang 编译器错误在 Windows 上显示 'No such file or directory'