Pergunta

I create a empty android project. then i add a new xml layout file with this content: 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>

and add a java class : MainActivity.java

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity
{
    @Override   
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); 
    }
}

the content of the AndroidManifest.xml is the below:

<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>

and when i run it on the emulated device(with this configuration: Nexus One 4.4.2 , API 19,CPU ARM)have lot of run time error. and in the logcat show:

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)

.....

Foi útil?

Solução

Uninstall the application from the emulated device and/or clear the emulator. One of these should solve your problem

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top