eclipse java.lang.UnsatisfiedLinkError:无法从加载器加载 aacdecoder
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23173587/
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
java.lang.UnsatisfiedLinkError: Couldn't load aacdecoder from loader
提问by CL22
I'm creating a "Hello World" AAC stream player.
我正在创建一个“Hello World”AAC 流播放器。
My steps:
我的步骤:
- In ADT Eclipse v22.6.2, I created a new Android Application, default settings for everything.
- Downloaded
aacdecoder-android-libs-0.8.zip
from here - Extracted it all to my project's
libs
folder.
- 在 ADT Eclipse v22.6.2 中,我创建了一个新的 Android 应用程序,所有内容的默认设置。
aacdecoder-android-libs-0.8.zip
从这里下载- 将其全部解压缩到我的项目
libs
文件夹中。
Added the following import to the Activity:
向活动添加了以下导入:
import com.spoledge.aacdecoder.AACPlayer;
Added the following to the end of the onCreate(...)
method:
在onCreate(...)
方法的末尾添加了以下内容:
AACPlayer aacPlayer = new AACPlayer();
aacPlayer.playAsync( "http://prem4.di.fm:80/trance?gzufXm01F8D2Y6hj2" );
And ran it. I got the error:
并运行它。我收到错误:
Could not find class 'com.spoledge.aacdecoder.AACPlayer', referenced from method com.example.cardi.MainActivity.onCreate
找不到从方法 com.example.cardi.MainActivity.onCreate 引用的“com.spoledge.aacdecoder.AACPlayer”类
After reading some SO questions, the only thing that jumped out at me was that the "Order and Export" tab in "Project" > "Properties" > "Java Build Path" needed playing with. Before:
在阅读了一些 SO 问题后,唯一让我想到的是“项目”>“属性”>“Java 构建路径”中的“订购和导出”选项卡需要使用。前:
I made a little bit of progress by changing it:
我通过改变它取得了一点进步:
- Checked the aacdecoder entry
- Moved the aacdecoder entry to the top
- 检查了 aacdecoder 条目
- 将 aacdecoder 条目移至顶部
Resulting in this error:
导致这个错误:
java.lang.UnsatisfiedLinkError: Couldn't load aacdecoder from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.cardi-1.apk,libraryPath=/data/app-lib/com.example.cardi-1]: findLibrary returned null
java.lang.UnsatisfiedLinkError: 无法从加载器 dalvik.system.PathClassLoader[dexPath=/data/app/com.example.cardi-1.apk,libraryPath=/data/app-lib/com.example.cardi 加载 aacdecoder -1]:findLibrary 返回 null
I feel stupid whenever I come back to Android. Please help!
每当我回到 Android 时,我都觉得自己很愚蠢。请帮忙!
回答by CL22
It turned out to be something really simple which had been pointed out in other questions and answers, but not made totally explicit. So for anyone else pulling out their hair, here it is, spoon fed:
结果证明这是一些非常简单的事情,在其他问题和答案中已经指出,但没有完全明确。所以对于其他拔头发的人来说,这是用勺子喂食的:
The library comes in a zip file, aacdecoder-android-libs-0.8.zip
.
该库以 zip 文件形式提供aacdecoder-android-libs-0.8.zip
。
It has the following directory structure:
它具有以下目录结构:
aacdecoder-android-libs-0.8.zip
> aacdecoder-android-libs-0.8
> aacdecoder-android-0.8.jar
> armeabi
> libaacdecoder.so
> armeabi-v7a
> libaacdecoder.so
> mips
> libaacdecoder.so
> x86
> libaacdecoder.so
What will NOT work is copying the contents of the zip to your application's libs
folder. Instead, you must copy the contents of the FOLDER WITHIN the zip file to the libs folder. So for example, the directory structure would be:
将 zip 的内容复制到您的应用程序libs
文件夹是行不通的。相反,您必须将 zip 文件中的文件夹的内容复制到 libs 文件夹。例如,目录结构将是:
In c:/users/me/EclipseWorkspace/Myproject/libs/
:
在c:/users/me/EclipseWorkspace/Myproject/libs/
:
> aacdecoder-android-0.8.jar
> armeabi
> libaacdecoder.so
> armeabi-v7a
> libaacdecoder.so
> mips
> libaacdecoder.so
> x86
> libaacdecoder.so
Then go to Project > Properties > Java Build Path > Libraries > Add JARs, and select the JAR package.
Then go to Project > Properties > Java Build Path > Order and Export. Check the JAR, and move it to the top.
然后转到 Project > Properties > Java Build Path > Libraries > Add JARs,然后选择 JAR 包。
然后转到项目 > 属性 > Java 构建路径 > 订购和导出。检查 JAR,并将其移至顶部。
Voila. Hair grows back
瞧。头发又长回来了
回答by hwg
I am not sure if you found the answer to your problem but mine was from the libs folder in my project being incorrectly named (was lib instead of libs). My issue was a result of accidentally deleting my project and having to restore it by extracting the APK from my phone. Once I renamed the folder, my issue was solved. Hope that helps.
我不确定您是否找到了问题的答案,但我的问题来自我项目中的 libs 文件夹被错误命名(是 lib 而不是 libs)。我的问题是由于不小心删除了我的项目并且不得不通过从我的手机中提取 APK 来恢复它。重命名文件夹后,我的问题就解决了。希望有帮助。
回答by manojprasad
check your lib folder does it contains filename.so file. This error we only get when this ndk files missed out.
检查您的 lib 文件夹是否包含 filename.so 文件。只有当这个 ndk 文件丢失时,我们才会得到这个错误。
Or your package name is not matching with your Native C or C++ code.
或者您的包名称与您的本机 C 或 C++ 代码不匹配。
example : your package name is com.example.project
and class name is Test
示例:您的包名是 com.example.project
,类名是Test
Then the method you call from JNI should be declared like below.
那么你从 JNI 调用的方法应该如下声明。
com_example_project_Test_sum(......) {
}
Here sumis the name of your native method. Hope this will help you.
这里sum是您的本地方法的名称。希望这会帮助你。