Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
811 views
in Technique[技术] by (71.8m points)

eclipse - caused by: java.lang.ClassNotFoundException

It is very frustrating that when running said app on a device or an emulator the "Unfortunately, app name has stopped" error came up. I believe that (by looking at the LogCat) I have pinpointed the problem to the error "java.lang.ClassNotFoundException". How I can fix this?

This is my manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.benchaful.newboard"
      android:versionCode="1"
      android:versionName="1.0">


    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="com.benchaful.newBoard.activity"
              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>
    <activity android:name="com.google.ads.AdActivity" 
          android:configChanges="keyboard|keyboardHidden|orientation" />
    </application>
    <uses-sdk android:targetSdkVersion="16" android:minSdkVersion="7" />
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>

This is my main layout file

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.benchaful.newboard"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

    <LinearLayout android:layout_width="fill_parent"
     android:id="@+id/home_layout"
     android:orientation="vertical"
     android:layout_height="wrap_content"
     android:background="#000000"
     >

There is some buttons here

<WebView 
    android:id="@+id/accesskey"
    android:layout_width="fill_parent"
    android:layout_height="100px"
/>


    </LinearLayout>
</ScrollView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/res/com.benchaful.newboard"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="#ffffff"
              android:gravity="bottom"
              android:layout_alignParentBottom="true"
              android:layout_alignBottom="@+id/home_layout"
              >
            <com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads"
                                 android:id="@+id/adView"
                                 android:layout_width="wrap_content"
                                 android:layout_height="wrap_content"
                                 ads:adUnitId="a151a7cc8c54403"
                                 ads:adSize="BANNER"
                                 />
    </LinearLayout>


    </RelativeLayout>

And this is my LogCat

06-06 20:03:05.355: E/AndroidRuntime(8409): FATAL EXCEPTION: main
06-06 20:03:05.355: E/AndroidRuntime(8409): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.benchaful.newboard/com.benchaful.newBoard.activity}: java.lang.ClassNotFoundException: com.benchaful.newBoard.activity
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2146)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread.access$700(ActivityThread.java:140)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.os.Looper.loop(Looper.java:137)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread.main(ActivityThread.java:4944)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at java.lang.reflect.Method.invokeNative(Native Method)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at java.lang.reflect.Method.invoke(Method.java:511)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at dalvik.system.NativeStart.main(Native Method)
06-06 20:03:05.355: E/AndroidRuntime(8409): Caused by: java.lang.ClassNotFoundException: com.benchaful.newBoard.activity
06-06 20:03:05.355: E/AndroidRuntime(8409):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
06-06 20:03:05.355: E/AndroidRuntime(8409):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2036)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Check the name of your class in manifest file.

change com.benchaful.newBoard.activity to com.benchaful.newBoard.activity.ComponentInfo

activity android:name="com.benchaful.newBoard.activity.ComponentInfo"...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...