microg/GmsCore · error · IllegalStateException

Resources have not been initialized

Error message

Resources have not been initialized

What it means

ResourcesContainer is a static holder that the embedding app (or map backend) must initialize via ResourcesContainer.set(Resources) before any code needs to resolve resources. get() throws IllegalStateException when set() was never called, because the library cannot inflate/inflate-locate map resources otherwise.

Source

Thrown at play-services-maps/core/vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java:30

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.microg.gms.maps.vtm;

import android.content.res.Resources;

public class ResourcesContainer {
    private static Resources resources;

    public static void set(Resources resources) {
        ResourcesContainer.resources = resources;
    }

    public static Resources get() {
        if (resources == null) {
            throw new IllegalStateException("Resources have not been initialized");
        } else {
            return resources;
        }
    }
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Call ResourcesContainer.set(context.getResources()) (typically in Application.onCreate) before using map APIs
  2. Ensure initialization also runs for every process declared in the manifest
  3. If embedding microG itself, verify the maps backend init path sets the container

Example fix

// before
GoogleMap map = getMap(); // ResourcesContainer not set
// after
ResourcesContainer.set(getApplicationContext().getResources());
GoogleMap map = getMap();
Defensive patterns

Strategy: validation

Validate before calling

// initialize once before using map APIs
if (ApplicationContextHolder.get() != null) {
    ResourcesContainer.set(ApplicationContextHolder.get().getResources());
}

Try / catch

try { Resources r = ResourcesContainer.get(); } catch (IllegalStateException e) { ResourcesContainer.set(context.getResources()); }

Prevention

When it happens

Trigger: Using the vtm maps backend (GoogleMapImpl and friends) without having called ResourcesContainer.set(context.getResources()) during app or backend initialization — e.g. using maps in a process that skips the usual initialization entry point.

Common situations: Running in a separate process (push, content provider) where the Application init code did not run; calling map APIs from an instrumented test; missing microG/extension initialization in a custom ROM integration.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/ecefb1e744582f5a. Report an issue: GitHub.