  We consider almost periodic stationary nonlinear Schr\"odinger equations in
dimension $1$. Under certain assumptions we prove the existence of nontrivial
finite energy solutions in the strongly indefinite case. The proof is based on
a carefull analysis of the energy functional restricted to the so-called
generalized Nehari manifold, and the existence and fine properties of special
Palais-Smale sequences. As an application, we show that certain one dimensional
almost periodic photonic crystals possess gap solitons for all prohibited
frequencies.
