1

再会。我在模拟器中启动程序时遇到问题。有一个代码:

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);

程序构建成功,但之后出现异常

java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
at java.util.Arrays.asList(Arrays.java:2828)
at com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings.addRecognizedFeatures(ParserConfigurationSettings.java:115)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(SAXParserImpl.java:189)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:81)
at com.android.sdklib.devices.DeviceParser.getParser(DeviceParser.java:371)
at com.android.sdklib.devices.DeviceParser.parse(DeviceParser.java:355)
at com.android.sdklib.devices.DeviceManager.loadDevices(DeviceManager.java:419)
at com.android.sdklib.devices.DeviceManager.getVendorDevices(DeviceManager.java:215)
at com.android.sdklib.devices.DeviceManager.getDevices(DeviceManager.java:167)
at com.android.sdklib.devices.DeviceManager.getDevice(DeviceManager.java:147)
at com.android.sdklib.devices.DeviceManager.getDeviceStatus(DeviceManager.java:136)
at com.android.sdklib.internal.avd.AvdManager.parseAvdInfo(AvdManager.java:1413)
at com.android.sdklib.internal.avd.AvdManager.buildAvdList(AvdManager.java:1325)
at com.android.sdklib.internal.avd.AvdManager.<init>(AvdManager.java:286)
at com.android.sdklib.internal.avd.AvdManager.getInstance(AvdManager.java:296)
at org.netbeans.modules.android.project.launch.AndroidLauncherImpl.configAvd(AndroidLauncherImpl.java:130)
at org.netbeans.modules.android.project.launch.AndroidLauncherImpl.launch(AndroidLauncherImpl.java:79)
at org.netbeans.modules.android.project.LaunchExecutor$1.taskFinished(LaunchExecutor.java:92)
at org.openide.util.Task.notifyFinished(Task.java:236)
at org.openide.util.Task.run(Task.java:256)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

你能帮我解决这个问题吗?谢谢。

PS Emulator 可以通过 AVD 管理器启动,但不能通过 Netbeans 启动。

4

2 回答 2

0

这里有一个错误报告,评论中有一个解决方法

解决。我安装了 Java 1.7u11 Rel 1.7.0_11,现在模拟器启动良好。

于 2013-01-29T12:06:58.663 回答
-1

你的事情有点不正常。您在创建布局项目之前抓取它们。

从:

setContentView(R.layout.main);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);

到:

setContentView(R.layout.main);
setContentView(tv);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
于 2013-01-29T12:04:39.137 回答