This paper endogenizes firms' choices of production technology in what would be a standard Melitz model otherwise. The responses of firms' productivity to trade liberalization are heterogenous: exporters, on average, improve their level of technology adoption, whereas nonexporters downgrade their level of technology adoption. The degree to which firms adjust production technology depends on domestic market size, export destination market size, trade impediments, and export status. The conflicting empirical results of the impact of trade liberalization on exporters' productivity are rationalized by showing that changes in different trade costs (variable vs. fixed costs) affect firms' productivity differently. We calibrate the model's parameters to match firms' characteristics in the global economy. The results indicate that endogenous productivity increases the gains from trade liberalization.