简体   繁体   中英

NoClassDefException, starting activity from another package

It's my first time using the Eclipse ADT and I'm having problems starting a new activity from a different package. I'm trying to start from but I keep getting a from failing to link my CameraActivity properly. 启动 ,但是由于无法正确链接我的CameraActivity,我一直得到I'm not exactly sure what I'm doing wrong and am in much need of guidance.

Any and all help would be greatly appreciated. Thanks.


AndroidManifest.xml

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

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

<supports-screens android:resizeable="true"
                  android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="true"
                  android:anyDensity="true" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <service
        android:name=".swipe.SocketService"
        android:icon="@drawable/ic_launcher"
        android:label="socket_service" >
    </service> 
    <activity
        android:name=".swipe.LobbyActivity"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.NoTitleBar" />
    <activity
        android:name=".cam.CameraActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

</application>

LobbyActivity.java

if (str.equalsIgnoreCase(KEY_START_GAME)) {
        Intent newIntent = new Intent(CONTEXT, CameraActivity.class);
        Bundle extras = new Bundle();
        extras.putString(KEY_USERNAME, username);
        extras.putString(KEY_MATCH, match);
        extras.putString(KEY_TEAM, team);
        newIntent.putExtras(extras);
        startActivity(newIntent);
}

LogCat

02-18 13:51:00.909: I/dalvikvm(12358): Failed resolving Lcom/furgus/cam/CameraActivity; interface 695 'Lorg/opencv/android/CameraBridgeViewBase$CvCameraViewListener2;'
02-18 13:51:00.909: W/dalvikvm(12358): Link of class 'Lcom/furgus/cam/CameraActivity;' failed
02-18 13:51:00.909: E/dalvikvm(12358): Could not find class 'com.furgus.cam.CameraActivity', referenced from method com.furgus.swipe.LobbyActivity.updateUI
02-18 13:51:00.909: W/dalvikvm(12358): VFY: unable to resolve const-class 565 (Lcom/furgus/cam/CameraActivity;) in Lcom/furgus/swipe/LobbyActivity;

Try this:

Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.

Hope this helps.

Try this:

First add jar to build path

project-> config build path-> order and export-> move dependent project on top

and

this error is also generated when you make an app that uses the Google API (such as Maps) but run it on a device that targets the Android API.

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