Phill Wiggins
Phill Wiggins

Reputation: 2917

The activity 'MainActivity' is not declared?! (Although it is)

I recently updated Android Studio and tried to import an old project. Having a number of issues with it and the configurations at the moment. It keeps saying that the activity 'MainActivity' is not declared. Can anyone spot an issue with this manifest and code?

Thanks in advance!!!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.purewowstudio.bodycal">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING" />

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"/>
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
    <activity
            android:name=".ui.MainActivity"
            android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.SettingsActivity"
        android:label="@string/app_name"
        android:parentActivityName=".ui.MainActivity">
    </activity>

    <activity android:name="com.google.android.gms.ads.AdActivity"

        android:theme="@android:style/Theme.Translucent" />


</manifest>

Upvotes: 0

Views: 2606

Answers (1)

JozeRi
JozeRi

Reputation: 3429

if I'm correct your problem is that you are closing your application tag before even entering your activities, here:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"/> <-- that's the problem.

replace the " /> " with " > ". and close it off at the end and try.

full fixed code :

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version"/>
<activity
        android:name=".ui.MainActivity"
        android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
<activity
    android:name=".ui.SettingsActivity"
    android:label="@string/app_name"
    android:parentActivityName=".ui.MainActivity">
</activity>

<activity android:name="com.google.android.gms.ads.AdActivity"

    android:theme="@android:style/Theme.Translucent" />

</application>
</manifest>

Hope that helped.

JozeRi.

Upvotes: 1

Related Questions