gpt4 book ai didi

java - 如何使用 AVD 正确运行 Android 应用程序?

转载 作者:行者123 更新时间:2023-11-30 03:06:41 25 4
gpt4 key购买 nike

我正在尝试运行我的第一个 Android 应用程序。我遵循 developer.android.com 上的“我的第一个应用程序”教程。

activity_main.xml 很简单:

<LinearLayout 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"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<EditText
android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_message" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/send_button" />

</LinearLayout>

MainActivity.java 是默认的。

问题是,当我运行我的 Andoid 应用程序时,它确实会打开新的虚拟设备,但屏幕是黑色的,并且右侧 Pane 中有几个按钮。所以我的 activity_main.xml 中没有显示任何内容。

在控制台中我看到这样的输出:

[2014-02-11 14:21:20 - MyFirstApp] ------------------------------
[2014-02-11 14:21:20 - MyFirstApp] Android Launch!
[2014-02-11 14:21:20 - MyFirstApp] adb is running normally.
[2014-02-11 14:21:20 - MyFirstApp] Performing com.example.myfirstapp.MainActivity activity launch
[2014-02-11 14:21:20 - MyFirstApp] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-02-11 14:21:34 - MyFirstApp] Launching a new emulator with Virtual Device 'MyVirtualDevice'
[2014-02-11 14:22:17 - MyFirstApp] emulator-5554 disconnected! Cancelling 'com.example.myfirstapp.MainActivity activity launch'!
[2014-02-11 14:22:54 - Emulator] Failed to create Context 0x3005
[2014-02-11 14:22:54 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2014-02-11 14:22:54 - Emulator] WARNING: Data partition already in use. Changes will not persist!
[2014-02-11 14:22:54 - Emulator] WARNING: SD Card image already in use: C:\Users\Vova\.android\avd\MyVirtualDevice.avd/sdcard.img
[2014-02-11 14:22:54 - Emulator] WARNING: Cache partition already in use. Changes will not persist!
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:54 - Emulator] could not get wglGetExtensionsStringARB
[2014-02-11 14:22:55 - Emulator] emulator: warning: opening audio input failed
[2014-02-11 14:22:55 - Emulator]
[2014-02-11 14:22:56 - MyFirstApp] New emulator found: emulator-5556
[2014-02-11 14:22:56 - MyFirstApp] Waiting for HOME ('android.process.acore') to be launched...
[2014-02-11 14:23:08 - MyFirstApp] emulator-5556 disconnected! Cancelling 'com.example.myfirstapp.MainActivity activity launch'!

我的 AndroidManifest.xml 是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.myfirstapp.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>
</application>

</manifest>

有什么问题吗?

谢谢!

最佳答案

欢迎来到 Android 开发世界。这里有几件事:

  1. 模拟器提示您正在尝试启动一个新的,而使用该图像的一个已经在运行。启动时选择现有的(正在运行的)模拟器。
  2. 检查以确保您在模拟器上运行的 API 级别与 list 中的内容相匹配(级别 18)
  3. 我强烈推荐使用 Genymotion - 这是一个非常(非常!!)更快的模拟器

关于java - 如何使用 AVD 正确运行 Android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21701875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com