I write programs on Java for Android. I am trying to hide my java code from decompilation. Is it possible to make .so library from java code?
To "hide my java code from decompilation" you should use proguard.
The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.
No obfuscation is perfect, but at least with proguard, the attacker can't get back to the same source code you started with.
And remember even with compiled c in a .so
it can be reverse engineered, so it's not like that's a better solution.