A novel energetic cocrystal consisting of the most powerful explosive used by military forces, octahydro-1,3,5,7-tetranitro-1,3,5,7-tetrazocine (HMX), and an insensitive explosive, 2,6-diamino-3,5-dinitropyridine-1-oxide (ANPyO), was prepared by a solvent/no-solvent method under the constraint of a 2D triaminoguanidine-glyoxal polymer. The results show that the optimum molar ratios of HMX and ANPyO in the HMX/ANPyO cocrystal should be 4:1 and 8:1 for better performance. The density of the hybrid cocrystal is slightly higher than those of both components. The scanning electron microscopy images show that the HMX/ANPyO cocrystals are of irregular polyhedron shape, whereas the obtained two types of cocrystals are plate-like with smooth surfaces. The X-ray diffraction spectra proved the successful formation of the cocrystals. The thermal analyses show that one of the cocrystals decomposes in a single step at a temperature of 284.1 °C, which is lower than that of ANPyO but higher than that of HMX. More importantly, the polymorphic transition of the cocrystal is largely inhibited, resulting in improved phase stability. The standard enthalpy of formation of the HMX/ANPyO cocrystal is higher than those of both HMX and ANPyO, and the highest one reaches 582.4 kJ·kg-1. Experiments and relevant calculations show that the best resultant hybrid HMX crystal has a detonation velocity of 9.82 km·s-1 and a pressure of 46.2 GPa.