Android Telegram 应用程序--> java.lang.UnsatisfiedLinkError:未找到 void 的实现
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33765946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Telegram App --> java.lang.UnsatisfiedLinkError: No implementation found for void
提问by stavasknall
Unfortunally a similar question was removed at Stackoverflow some weeks ago, I must make a new question.
不幸的是,几周前在 Stackoverflow 上删除了一个类似的问题,我必须提出一个新问题。
Im trying to build an own Telegram app for android via source @ https://github.com/DrKLO/Telegram
我试图通过源@ https://github.com/DrKLO/Telegram为 android 构建自己的 Telegram 应用程序
I can not get it to work, it stops on startup with the following error, any ideas on where to start, Im quite new to Android Studio.
我无法让它工作,它在启动时停止并出现以下错误,关于从哪里开始的任何想法,我对 Android Studio 很陌生。
11-17 19:55:04.142 2667-2667/org.telegram.messenger E/art: No implementation found for void org.telegram.tgnet.ConnectionsManager.native_setJava(boolean) (tried Java_org_telegram_tgnet_ConnectionsManager_native_1setJava and Java_org_telegram_tgnet_ConnectionsManager_native_1setJava__Z)
11-17 19:55:04.142 2667-2667/org.telegram.messenger D/AndroidRuntime: Shutting down VM
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: FATAL EXCEPTION: main
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: Process: org.telegram.messenger, PID: 2667
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void org.telegram.tgnet.ConnectionsManager.native_setJava(boolean) (tried Java_org_telegram_tgnet_ConnectionsManager_native_1setJava and Java_org_telegram_tgnet_ConnectionsManager_native_1setJava__Z)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at org.telegram.tgnet.ConnectionsManager.native_setJava(Native Method)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at org.telegram.messenger.ApplicationLoader.onCreate(ApplicationLoader.java:259)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.app.ActivityThread.-wrap1(ActivityThread.java)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
回答by Jesús Castro
The main problem is that you're running the project without generating the native library from the C/C++ codes. Because of that project based on Telegram, which you point it out with the link, has the file Android.mk
on the jni
directory , you have to compile the code manually. I fixed that exception following these steps:
主要问题是您运行项目时没有从 C/C++ 代码生成本机库。因为那个基于 Telegram 的项目,你用链接指出它,Android.mk
在jni
目录中有文件,你必须手动编译代码。我按照以下步骤修复了该异常:
- Check that
build.gradle
contains:
- 检查
build.gradle
包含:
source version 3.13.1 and newer:
sourceSets.main.jniLibs.srcDirs = ['./jni/']
source version lower than 3.13.1:
sourceSets.main { jniLibs.srcDirs = 'libs' jni.srcDirs = [] //disable automatic ndk-build call }
源版本 3.13.1 及更新版本:
sourceSets.main.jniLibs.srcDirs = ['./jni/']
低于 3.13.1 的源版本:
sourceSets.main { jniLibs.srcDirs = 'libs' jni.srcDirs = [] //disable automatic ndk-build call }
- Download the NDK
- 下载NDK
Proceed according to your operating system.
根据您的操作系统进行操作。
Linux / Mac
Linux / Mac
$ cd <path-to-Telegram>/TMessagesProj
$ <path-to-ndk>/ndk-build
Windows
视窗
- Download Cygwin
Add on
.bashrc
file, which is placed on Cygwin root directory (use some utility to find that file). In my case, the file was placed inC:\cygwin64\home\myuser
.export ndkbuild=/cygdrive/partition_name/your_ndk_directory/ndk-build.cmd
Open the Cygwin terminal and move yourself towards the
jni
directory of the project:cd /cygdrive/your_partition_name/project_jni_directory_path
Write
$ndkbuild
and wait the compiler finishes its task. If this process is right, two directories will show up,obj
andlibs
. Check thatlibs
directory contains some library with.so
extension. Finally, run the project.
- 下载Cygwin
添加
.bashrc
文件,该文件位于 Cygwin 根目录中(使用一些实用程序来查找该文件)。在我的情况下,文件被放置在C:\cygwin64\home\myuser
.export ndkbuild=/cygdrive/partition_name/your_ndk_directory/ndk-build.cmd
打开 Cygwin 终端并将自己移至
jni
项目目录:cd /cygdrive/your_partition_name/project_jni_directory_path
写入
$ndkbuild
并等待编译器完成其任务。如果这个过程是正确的,会出现两个目录,obj
和libs
. 检查该libs
目录包含一些带.so
扩展名的库。最后,运行项目。
回答by Navid Eivazzadeh
As Jesús Castro mentioned, you have to compile native codes to libraries with .so
suffix that android can use them for running app.
正如 Jesús Castro 所提到的,您必须将本机代码编译为带有.so
后缀的库,以便 android 可以使用它们来运行应用程序。
But why this is happened newly? Because in the last commit of DrKLO's Telegram repository they have removed the prebuilt libraries according to commit message in git:
但为什么这是新发生的呢?因为在 DrKLO 的 Telegram 存储库的最后一次提交中,他们根据 git 中的提交消息删除了预构建的库:
Removing prebuilt libraries. The source code for all libraries is (and always was) available here: https://github.com/DrKLO/Telegram/tree/master/TMessagesProj/jni
删除预构建的库。所有库的源代码(并且一直)在此处可用:https: //github.com/DrKLO/Telegram/tree/master/TMessagesProj/jni
You can find the commit here.
你可以在这里找到提交。
回答by FeelCode
So, to solve your issue, you can remove your 64-bit libs from your build, or set abiFilters to package only 32-bit architectures:
因此,为了解决您的问题,您可以从构建中删除 64 位库,或将 abiFilters 设置为仅打包 32 位架构:
android {
....
defaultConfig {
....
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
}
}
add android.useDeprecatedNdk=true to a file named gradle.properties at the root of your project
将 android.useDeprecatedNdk=true 添加到项目根目录下名为 gradle.properties 的文件中
回答by Ishmael Chibvuri
@Rajsundar . If adding the line :
@Rajsundar。如果添加行:
export ndkbuild=/cygdrive/c/android-ndk-r10e/ndk-build.cmd
is not working. After doing everything else you can simply run the command directly from the jni directory.
不管用。完成其他所有操作后,您只需直接从 jni 目录运行命令即可。
/cygdrive/c/android-ndk-r10e/ndk-build.cmd
回答by testing
I had a similar error message. The solution for me was to deinstall the app from the simulator, clean the project (including all libraries) and do a rebuild. Now the app starts fine.
我有一个类似的错误信息。我的解决方案是从模拟器中卸载应用程序,清理项目(包括所有库)并进行重建。现在应用程序启动正常。