简体   繁体   English

Eclipse Android配置问题

[英]Eclipse android configuration issue

I've been setting up my Android SDK and ADT Plugin in Eclipse this morning and my first couple of tests when building an android app have worked fine. 今天上午,我一直在Eclipse中设置我的Android SDKADT Plugin ,而在构建android应用程序时,我的前几次测试工作正常。

However now I'm starting to get a pop-up everytime I click on something saying AN ERROR HAS OCCURED - JAVA.NULLPOINTER.EXCEPTION . 但是,现在我每次单击表示已发生AN ERROR HAS OCCURED - JAVA.NULLPOINTER.EXCEPTION开始弹出窗口AN ERROR HAS OCCURED - JAVA.NULLPOINTER.EXCEPTION

I understand a nullpointer exception in Java is when something has been created but I haven't even typed in any code yet its just a standard mainactivity class created by the app creation wizard when you click new project. 我知道Java中的nullpointer异常是在创建了某些东西之后,但我什至没有输入任何代码,但是它只是单击创建新项目时由应用程序创建向导创建的标准mainactivity类。

The problems started when I ran the program and it seemed to have had an issue with Activity_mainlayout.out.xml or whatever its called. 当我运行程序时,问题就开始了,它似乎与Activity_mainlayout.out.xml或其任何调用有问题。

Anyone got any ideas as to why this happening it was working before and I haven't begun to code my application. 任何人都知道为什么发生这种情况之前它是有效的,而且我还没有开始编写我的应用程序的代码。

Few details: Eclipse using the Android ADT Plugin and Android SDK with an Android Virtual Device for testing. 很少有细节:Eclipse使用Android ADT插件和Android SDK与Android虚拟设备进行测试。

Thanks guys. 多谢你们。

Ps I deleted the project in windows explorer and in Eclipse so got rid of it completely and any new project now is producing the same pop-up error. 附言:我在Windows资源管理器和Eclipse中删除了该项目,因此完全删除了该项目,现在任何新项目都会产生相同的弹出错误。


This is the code for MainActivity 这是MainActivity的代码

package wag.cymal.libraryportal.welshlibraries;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;
import android.graphics.*;
import android.graphics.drawable.Drawable;

@SuppressWarnings("unused")
public class MainActivity extends Activity {

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

    LinearLayout ll = new LinearLayout(this);
    ll.setBackgroundResource(R.drawable.natlib); // background image
    this.setContentView(ll);
}

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

} }

And the activity_main XML file: 还有activity_main XML文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:padding="@dimen/padding_medium"
    android:text="@string/hello_world"
    tools:context=".MainActivity" />

Any ideas? 有任何想法吗? :/ :/

The 'sctivity_mainlayout.out.xml' is created when you try to run the aplication while you are in an xml file. 当您在xml文件中时尝试运行应用时,将创建“ sctivity_mainlayout.out.xml”。 As far I understand, the compiler tries to compile the xml file, and this generates the .out.xml file, which is not valid xml, and this causes an error. 据我了解,编译器会尝试编译xml文件,这会生成.out.xml文件,该文件不是有效的xml,并会导致错误。

Solution: delete the .out.xml file, and always when you run watch out that the editor has focus in java file (or none)... 解决方案:删除.out.xml文件,并始终在运行时注意编辑器将焦点放在Java文件上(或没有)...

Now if for some reason your eclipse is messed up, try running it with the option --clean (using the command line, or in the case of Windows, also "execute" option -> " c:\\mypathtoeclipse\\eclipse.exe --clean "). 现在,如果由于某种原因您的日食混乱了,请尝试使用--clean选项运行它(使用命令行,或者在Windows中,也可以使用“执行”选项->“ c:\\mypathtoeclipse\\eclipse.exe --clean “)。 This makes eclipse itself to be rebuilt. 这使Eclipse本身得以重建。 In my case it has fixed several times some unexplainable, unexpected exceptions I got during workspace load. 就我而言,它修复了我在工作空间加载期间遇到的一些无法解释的意外异常。

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

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