What shall i do if i receave this message "have you declared this activity in your AndroidManifest.xml?"

huangapple go评论57阅读模式
英文:

What shall i do if i receave this message "have you declared this activity in your AndroidManifest.xml?"

问题

我正在开发一个项目来完成我的学业,但我正在从零开始学习Android,感觉很困难。我尝试将两个不同的项目组合在一起。第一个是一个井字棋游戏,当我点击选项菜单项时它会打开,而第二个游戏不会打开,而是崩溃,并出现错误消息:"您是否在AndroidManifest.xml中声明了此活动?" 我尝试了很多方法,但都没有成功。我认为问题可能在于选项菜单中对应项目的OnOptionsItemSelected方法,但我不知道如何解决它,有人能帮助吗?对可能存在的错误表示抱歉 xD 我的清单文件

英文:

im developing a project to finish my school but im learnig android from the ground and its being hard.
Im trying to put togeter 2 diferent projects. The first one which is an tic tac toe game it's openning when I click the options menu item that was declared to it but my second game its not oppening and it crashes and an error appers: "Have you declared this activity in your AndroidManifest.xml?"

I tryied several things but nothing works . I think it may be a leak of the OnOptionsItemSelected of the item that corresponds in the options menu, but i dont know how to solve it, someone to help it?
Sry for possible errors xD
my manifest xml

答案1

得分: 1

我可以帮你翻译以下部分:

"Can you paste the code of your AndroidManifest.xml file?" -> "你能粘贴你的AndroidManifest.xml文件的代码吗?"

"I believe you forgot to mention your Activity there." -> "我相信你忘记在那里提及你的Activity了。"

"If it's one single Activity, you need to make sure you'll have it with an intent-filter on it." -> "如果只有一个Activity,确保你在它上面添加了一个intent-filter。"

"If it's another activity, you just need to declare it in your Manifest file without the intent-filter block on it." -> "如果是另一个Activity,只需在Manifest文件中声明它,不需要intent-filter块。"

"You must declare all of your activities in your Manifest file." -> "你必须在Manifest文件中声明所有的Activity。"

"Edit: I just saw you attached a screenshot of your Manifest file. What is the name of the activity you are trying to open when click on the menu item?" -> "编辑:我刚刚看到你附上了Manifest文件的截图。当点击菜单项时,你尝试打开的Activity名称是什么?"

英文:

Can you paste the code of your AndroidManifest.xml file?

I believe you forgot to mention your Activity there.
If it's one single Activity, you need to make sure you'll have it with an intent-filter on it.

If it's another activity, you just need to declare it in your Manifest file without the intent-filter block on it.

You must declare all of your activities in your Manifest file.
e.g

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

    <application
        ...>

        <activity
            android:name="name of your main activity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="name of your second activity">

    </application>

</manifest>

Edit:
I just saw you attached a screenshot of your Manifest file.
What is the name of the activity you are trying to open when click on the menu item?

huangapple
  • 本文由 发表于 2023年4月13日 23:32:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定