android中的简单问候语
我创建了一个空的android项目。然后我添加一个新的xml布局文件,内容如下:activity_main.xmlandroid中的简单问候语,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
<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)