Register Application class in Manifest?

AndroidAndroid Manifest

Android Problem Overview


I have one Application class to keep the global state of my application. But I'm unable to register it in Manifest file? Any idea how to do this?

Android Solutions


Solution 1 - Android

If it derives from Application, add the fully qualified (namespace + class name) as the android:name parameter of the application element in your manifest.

<application
    	android:name="com.you.yourapp.ApplicationEx"

Or if the class' package can be described as relative to the package in the manifest tag, then just start with a .:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.you.yourapp">

    <application
        android:name=".ApplicationEx"

Solution 2 - Android

but in case you are already using some library like branch.io's library then most probably your manifest

<application name="">

property will already have some name like

`<application name="io.referral.BranchApp">

in that case you need to first extend your application class, like below:

public class Application extends BranchApp

and then register your application in manifest as:

android:name="absdevelopers.com.brankreferal.Application"

this works perfectly for me :) i hope it helps someone in trouble :)

Solution 3 - Android

If you are using a MultiDex application you will already have "android:name" in use so instead extend android.support.multidex.MultiDexApplication:

public class MyApplication extends MultiDexApplication {...}

And add it to the Android manifest:

android:name="app.package.MyApplication"

Solution 4 - Android

If the activity is included as a dependency that you can lauch a class this should solve it in 2021.

Add tools:ignore="MissingClass" to your activity element in the Android manfifest file

example

<activity
            android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
            android:screenOrientation="portrait"
            android:theme="@style/LicensesTheme"
            tools:ignore="MissingClass"/>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSharjeelView Question on Stackoverflow
Solution 1 - AndroidRichView Answer on Stackoverflow
Solution 2 - AndroidBawaView Answer on Stackoverflow
Solution 3 - AndroidAnos K. MhazoView Answer on Stackoverflow
Solution 4 - AndroidJimmy KaneView Answer on Stackoverflow