Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的简单问候语_Android_Android Activity_Xml Layout - Fatal编程技术网

android中的简单问候语

android中的简单问候语,android,android-activity,xml-layout,Android,Android Activity,Xml Layout,我创建了一个空的android项目。然后我添加一个新的xml布局文件,内容如下:activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/first_page" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" an

我创建了一个空的android项目。然后我添加一个新的xml布局文件,内容如下:activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/first_page"
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=".MainActivity">    
</RelativeLayout>
AndroidManifest.xml的内容如下所示:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.worldcup2014"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity  android:name="com.worldcup2014.MainActivity"
            android:label="@string/app_name" 
            android:screenOrientation="portrait">            
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

…从模拟设备卸载应用程序和/或清除仿真器。其中一个应该可以解决您的问题

MainActivity.java
应该在
com.worldcup2014
包中。我看不到该文件顶部的
声明从模拟设备卸载应用程序或清除模拟器。其中一个应该可以解决您的问题粘贴
MainActivity.java
的第一行
package
,您能确保是否将MainActivity文件保存在同一个包中或src文件夹中的同一文件夹结构中吗?如果问题出在包中,据我所知,异常将是“Activity Not Found exception”
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.worldcup2014"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity  android:name="com.worldcup2014.MainActivity"
            android:label="@string/app_name" 
            android:screenOrientation="portrait">            
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
04-17 06:45:23.300: E/AndroidRuntime(1448): FATAL EXCEPTION: main
04-17 06:45:23.300: E/AndroidRuntime(1448): Process: com.worldcup2014, PID: 1448
04-17 06:45:23.300: E/AndroidRuntime(1448): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.worldcup2014/com.worldcup2014.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.worldcup2014.MainActivity" on path: DexPathList[[zip file "/data/app/com.worldcup2014-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.worldcup2014-1, /system/lib]]
04-17 06:45:23.300: E/AndroidRuntime(1448):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)