尝试运行基本的Hello World应用程序时出错

时间:2019-01-13 04:55:52

标签: java android xml

每当我尝试运行我的应用程序时,我都会不断收到此消息“错误运行的应用程序找不到默认活动”。

我尝试清理项目并重建,并使缓存/重新启动无效。我尚未编写任何代码,因为这是默认的hello world应用程序,因此我不确定为什么收到此消息。

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>







<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:context="com.example.android.ipokelist.MainActivity">

</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

您在XML代码中缺少了TextView。以下内容将为您提供帮助。

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout 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"
        tools:context="com.example.android.ipokelist.MainActivity">

    <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:text="Hello, World!"
          tools:context=".MainActivity" />

    </android.support.constraint.ConstraintLayout>

有关更多信息,请访问:https://www.androidfflap.com/learn-android

相关问题