本文介绍了错误:AndroidManifest.xml文件丢失 - >我在想什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是完全新的Andr​​oid的编程和我要求可能会是一件很简单的问题,但我没有关于如何使它工作的任何想法,所以恳请包涵。

我在安装Android的SDK和相关工具的 Android开发者网站。我跟着他们的指示创建的HelloWorld应用程序,但我得到了一些错误,我不明白。

该文件MainActivity.java是一个自动生成的文件,我不断收到错误在这个文件在这些地方:

  @覆盖
公共无效的onCreate(包savedInstanceState){
  super.onCreate(savedInstanceState);
  的setContentView(R.layout.activity_main); //在activity_main错误
}

@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
  。getMenuInflater()膨胀(R.menu.activity_main,菜单); //在activity_main错误
   返回true;
 }
 

于是我去了,想看看通过生成的类文件layout.class,发现没有变量调用activity_main那里。

谁能好心建议在这里做什么?任何帮助会深深AP preciated。

的目录结构显示了我,我有AndroidManifest.xml中。

当我尝试运行应用程序时,我得到这个特定的错误:

  AndroidManifest.xml文件丢失!
     未知的Andr​​oid包装问题
 

这些是一些我试图把它运行时,得到错误的:

  10-10 23:31:11.305:E /跟踪(946):错误打开跟踪文件:没有这样的文件或目录(2)
        10-10 23:31:11.955:E / AndroidRuntime(946):致命异常:主要
        10-10 23:31:11.955:E / AndroidRuntime(946):android.content.res.Resources $ NotFoundException:资源ID#0X2
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.content.res.Resources.getValue(Resources.java:1013)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.content.res.Resources.loadXmlResourceParser(Resources.java:2098)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.content.res.Resources.getLayout(Resources.java:852)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.view.MenuInflater.inflate(MenuInflater.java:107)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.example.myfirstapp.MainActivity.onCreateOptionsMenu(MainActivity.java:18)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.app.Activity.onCreatePanelMenu(Activity.java:2476)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.android.internal.policy.impl.PhoneWindow preparePanel(PhoneWindow.java:393)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.android.internal.policy.impl.PhoneWindow $ 1.运行(PhoneWindow.java:2913)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.os.Handler.handleCallback(Handler.java:615)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.os.Handler.dispatchMessage(Handler.java:92)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.os.Looper.loop(Looper.java:137)
        10-10 23:31:11.955:E / AndroidRuntime(946):在android.app.ActivityThread.main(ActivityThread.java:4745)
        10-10 23:31:11.955:E / AndroidRuntime(946):在java.lang.reflect.Method.invokeNative(本机方法)
        10-10 23:31:11.955:E / AndroidRuntime(946):在java.lang.reflect.Method.invoke(Method.java:511)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786)
        10-10 23:31:11.955:E / AndroidRuntime(946):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        10-10 23:31:11.955:E / AndroidRuntime(946):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

刚刚建立您的项目或清洁它作为下述克莱顿。

项目>全部构建

项目>清除

这相信是因为你没有R.java文件在您的根文件夹中。建设项目将产生在你的文件夹中的 R.java 文件和错误应该消失。

这是因为你指的是您的布局文件中使用下面的code

 的setContentView(R.layout.activity_main);
 

提及 R.layout.activity_main R.java 文件,该文件需要由产生申报建设项目。

Hi I am completely new to Android programming and the question I am asking might be something very simple, but I do not have any idea about how to make it work, so kindly bear with me.

I installed android-sdk and related tools from the Android developer site. I followed their instructions to create a HelloWorld app, but I am getting some errors which I don't understand.

The file MainActivity.java is an auto generated file and I keep getting errors in this file in these places:

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main); // error in activity_main
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.activity_main, menu); // error in activity_main
   return true;
 }

So I went and tried to look through the generated class file for layout.class and found there is no variable called activity_main there.

Can anyone kindly suggest what to do here? Any help will be deeply appreciated.

The directory structure shows me that I do have the AndroidManifest.xml.

When I try to run the app, I get this specific error:

     AndroidManifest.xml file missing!
     Unknown Android Packaging Problem

These are some of the errors that i am getting when trying to get it running :

        10-10 23:31:11.305: E/Trace(946): error opening trace file: No such file or directory (2)
        10-10 23:31:11.955: E/AndroidRuntime(946): FATAL EXCEPTION: main
        10-10 23:31:11.955: E/AndroidRuntime(946): android.content.res.Resources$NotFoundException: Resource ID #0x2
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.content.res.Resources.getValue(Resources.java:1013)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:2098)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.content.res.Resources.getLayout(Resources.java:852)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.view.MenuInflater.inflate(MenuInflater.java:107)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.example.myfirstapp.MainActivity.onCreateOptionsMenu(MainActivity.java:18)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.app.Activity.onCreatePanelMenu(Activity.java:2476)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2913)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.os.Handler.handleCallback(Handler.java:615)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.os.Handler.dispatchMessage(Handler.java:92)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.os.Looper.loop(Looper.java:137)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at android.app.ActivityThread.main(ActivityThread.java:4745)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at java.lang.reflect.Method.invokeNative(Native Method)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at java.lang.reflect.Method.invoke(Method.java:511)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        10-10 23:31:11.955: E/AndroidRuntime(946):  at dalvik.system.NativeStart.main(Native Method)
解决方案

Just build your project or Clean it as "Clayton" mentioned below.

Project > Build All

Project > Clean

This I believe is because you do not have R.java file in your gen folder. Building your project will generate the R.java file in your gen folder and the errors should go away.

This happens because you're referring to your layout file using the following code

setContentView(R.layout.activity_main);

The reference to R.layout.activity_main is declared in R.java file which needs to be generated by building your project.

这篇关于错误:AndroidManifest.xml文件丢失 - >我在想什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:06