我正在Eclipse中构建第一个Android应用程序(Luna Service Release 1(4.4.1))。我在系统上下载了所有Eclipse插件和AVD(参见截图)。
当我跑到下面时发生错误
无法在设备' emulator-5554上安装HelloWorldAndriodApp.apk!
(空值)
发布已取消!
我在谷歌(包括Stack Overflow)上经历了许多与此类似的链接,并尝试了解决方案1.将ADB连接超时增加到500000 2.清理构建应用程序3.重置ADB 在所有这些练习之后,我开始得到另一个例外 [2015-11-30 12:50:19 - HelloWorldAndriodApp]安装错误:未知失败 [2015-11-30 12:50:19 - HelloWorldAndriodApp]请查看logcat输出以获取更多详细信息。 [2015-11-30 12:50:23 - HelloWorldAndriodApp]发布取消了!
由于所有这些错误,我的应用程序没有初始化,只能看到黑屏与Android'模拟器屏幕中间的文本。
请提出一些解决方法来摆脱这些错误。
的AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworldandriodapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
Java类
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
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"
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="com.example.helloworldandriodapp.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
的strings.xml
<resources>
<string name="name">Type your name</string>
<string name="app_name">HelloWorldAndriodApp</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>
Log Cat:
11-30 00:44:44.080: E/EGL_emulation(2502): Failed to establish connection with the host
11-30 00:44:44.180: E/(2502): Failed to connect to host (QemuPipeStream)!!!
11-30 00:44:44.180: E/EGL_emulation(2502): Failed to establish connection with the host
11-30 00:44:44.200: E/(2502): Failed to connect to host (QemuPipeStream)!!!
11-30 00:44:44.200: E/EGL_emulation(2502): Failed to establish connection with the host
11-30 00:44:44.220: E/(2502): Failed to connect to host (QemuPipeStream)!!!
11-30 00:44:44.220: E/EGL_emulation(2502): Failed to establish connection with the host
11-30 00:44:44.220: E/(2502): Failed to connect to host (QemuPipeStream)!!!
11-30 00:44:44.260: E/EGL_emulation(2502): Failed to establish connection with the host
11-30 00:45:26.580: E/PowerManagerService-JNI(2784): Couldn't load power module (No such file or directory)
11-30 00:45:57.330: E/memtrack(2804): Couldn't load memtrack module (No such file or directory)
11-30 00:45:57.330: E/android.os.Debug(2804): failed to load memtrack module: -2
11-30 00:46:12.840: E/SurfaceFlinger(55): ro.sf.lcd_density must be defined as a build property
答案 0 :(得分:1)
代码很好,应该工作,问题必须是模拟器。
PS:另外,我建议使用Android Studio进行Android开发。我最近开始使用它,让一切变得如此简单。