EDITED my question: Is there any encoders from PCM raw data to any audio file? mp3,ogg... but not WAV, as it will be too big
I do have a text file which has raw PCM
I think, you must check the licensing issues first. AFAIK mp3 software has never been free. Linux did support mp3, but had to build the code on the local machine instead of downloading a ready-to-use package. (Not sure if this has changed in recent years.)
[Re: EDITED] Other formats are easier, e.g.:
How to encode Recorded voice to ogg vorbis?
How to convert the WAV/OGG file to FLAC file in Android?
there is a github project that provides lame encoder for android
https://github.com/intervigilium/liblame
there is also an sample app that uses the library
https://github.com/intervigilium/Lame4Android
but as allready stated, if you want to encode/decode a mp3 file you may have to pay license/patent fees.
here you can find the mp3 license prices
http://mp3licensing.com/royalty