I am not saying it won't work, I don't know, I never tried it. But if it was me, I would use the G2 as a normal, handheld flashlight, not attached, to the AR15. It is very easy to do, and is perfectly effective.
Not only would it work just as well, but you would also have a flashlight, for use as a normal flashlight, plus you would have a flashlight if you need to transition to your sidearm.
To use the flashlight with the rifle, screw the tailcap in until the light comes on. Now back the tailcap off just enough that the light goes off. Now hold the flashlight in your weak hand. Grasp the weapon with the flashlight between your fingers and the handguard. You are holding the weapon just as you normally do, except you have a flashlight under your fingers. If you press the side of the flashlight against the handguard with your fingers, the light will come on. Release the pressure and the light goes off. Of course it is always good to have a lanyard on your flashlight so that you can easily make magazine changes, transitions, and malfunction clearences without losing the light. Another way to use the G2 with an AR15 is to hold the flashlight in your weak hand and press the tailcap switch against the front of the magazine housing. I personally like the first method better but either will work.