How is this .g4 even created ?
It is not automatically created: you write it yourself.
Is there a way to convert antlrv3 .g file to one compatible with antlrv4 ?
No, AFAIK, there is no tool to convert a v3 ANTLR grammar to a v4 version.
Question
The grammar files for smali present here are for antlrv3. I couldnt find any .g4 file for smali. How is this .g4 even created ? Is there a way to convert antlrv3 .g file to one compatible with antlrv4 ?
Solution
How is this .g4 even created ?
It is not automatically created: you write it yourself.
Is there a way to convert antlrv3 .g file to one compatible with antlrv4 ?
No, AFAIK, there is no tool to convert a v3 ANTLR grammar to a v4 version.