I am trying to encode aac audio using android AudioRecord and MediaCodec. I have created a encoder class very similar to (Encoding H.264 from camera with Android MediaCodec)
Check "testEncoder" method here for how to use MediaCodec as Encoder properly.
after that In your code,
your input(audio recorder) is configured for single audio channel while your output(ADTS packet header) is set for two channels(chanCfg = 2).
also if you change your input samplerate (currently 44.1khz) you also have to change freqIdx flag in ADTS packet header. check this link for valid values.
And ADTS header profile flag is set to "AAC LC", you can also found this under MediaCodecInfo.CodecProfileLevel. you have set profile = 2 that is MediaCodecInfo.CodecProfileLevel.AACObjectLC