简体   繁体   中英

unable to instantiate component info

I'm trying to get a simple 'hello world' to show up in an emulator but I get the error below. I've tried everything from cleaning, adding .jar files, to moving external file up in the order in "Order and Export" and deleting the bin and gen folders and rebuilding. Not sure what I'm doing wrong. Please help.

Thanks.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{src.testapp.two/src.testapp.two.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "src.testapp.two.MainActivity" on path: DexPathList[[zip file "/data/app/src.testapp.two-1.apk"],nativeLibraryDirectories=[/data/app-lib/src.testapp.two-1, /system/lib]]

Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="src.testapp.two"
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=".MainActivity"
        android:label="@string/hello_world" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</manifest>

MainActivity Class

package testapp.two;

import testapp.two.R;
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 package name in Manifest and Class should be same in order to run your app. So, Please change either of the one to make them equal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM