简体   繁体   English

未声明活动“ MainActivity”? (虽然是)

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

I recently updated Android Studio and tried to import an old project. 我最近更新了Android Studio,并尝试导入一个旧项目。 Having a number of issues with it and the configurations at the moment. 目前,它及其配置存在许多问题。 It keeps saying that the activity 'MainActivity' is not declared. 它一直说没有声明活动“ MainActivity”。 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>

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. JozeRi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM