0

I'm creating a "Hello World" AAC stream player.

My steps:

  1. In ADT Eclipse v22.6.2, I created a new Android Application, default settings for everything.
  2. Downloaded aacdecoder-android-libs-0.8.zip from here
  3. Extracted it all to my project's libs folder.

Added the following import to the Activity:

import com.spoledge.aacdecoder.AACPlayer;

Added the following to the end of the onCreate(...) method:

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

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:

enter image description here

I made a little bit of progress by changing it:

  • Checked the aacdecoder entry
  • Moved the aacdecoder entry to the top

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

I feel stupid whenever I come back to Android. Please help!

Jodes
  • 14,118
  • 26
  • 97
  • 156
  • I had a similar problem...project had no errors, except file write permissions were locked...after enabling write The error stopped... – CrandellWS Aug 08 '14 at 18:16
  • May be [this link][1] will help you... [1]: http://stackoverflow.com/a/25347930/3843374 – Paritosh Dec 08 '14 at 04:55

3 Answers3

6

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.

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:

In 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.

Voila. Hair grows back

Jodes
  • 14,118
  • 26
  • 97
  • 156
1

check your lib folder does it contains filename.so file. This error we only get when this ndk files missed out.

Or your package name is not matching with your Native C or C++ code.

example : your package name is com.example.project and class name is Test

Then the method you call from JNI should be declared like below.

com_example_project_Test_sum(......) {

}

Here sum is the name of your native method. Hope this will help you.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
manojprasad
  • 158
  • 2
  • 8
1

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.

hwg
  • 285
  • 1
  • 2
  • 10