when open the android application, happen "Didn't find class "com.example.hello.hello" on path "

StackOverflow https://stackoverflow.com/questions/22894293

  •  28-06-2023
  •  | 
  •  

質問

I have this error "Didn't find class "com.example.hello.hello" on path".

hello/AndroidManifest.xml is

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


    <activity 
          android:name="hello"
          android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
</application>

</manifest>

link is picture, show the code and error window

I think the problem is

android:name="hello"

How do I fix it?

役に立ちましたか?

解決

You should put the full package name to your activity there. Example:

android:name="com.example.hello.MainActivity"

EDIT

Now that we know you have an empty src folder, you need to add a package that matches your Android package name in your manifest. Right click on your src folder and New -> Package. Name it "com.example.hello". Then right click on this new package and choose New -> Class. Name this MainActivity.

You will probably want to read some tutorials on what you need to do to create the code for an activity.

他のヒント

Check the name of your activity class, it's probably Hello (Uppercase) or MainActivity (if you followed the wizard template), and as dcharms pointed out prepend the package name to it, "com.example.hello.Hello" or "com.example.hello.MainActivity"

there is a problem in your activity name in manifest and the class you crated. your activity should be defined

    android:name="com.example.hello.hello"

this way where hello is the activity you created in your hello package.

Go through your naming conventions once again and also try to post the whole stack-trace

According to your screenshots, your src folder is empty, which means you are minimum missing your "hello" activity.

Please implement if first, or read this. You could choose Blank Activity when creating android project with eclipse to have it generated.

When you specify the name of activity, mind the preceding dot :

<activity 
          android:name=".MyFirstActivity"

otherwise, you would need full class name, such as "com.example.hello.MyFirstActivity"

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top