android:ClassNotFoundException尝试启动phonegap活动时

时间:2012-06-19 18:40:21

标签: android cordova

我有一个phonegap活动,我想通过按下按钮启动:

shareButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent activity = new Intent(context, GalleryActivity.class);
                context.startActivity(activity);
            }
        });

问题是:每当我想开始活动时,我都会听到以下错误:

  

java.lang.NoClassDefFoundError:net.myns.lib.cutoutcam.GalleryActivity

活动如下:

package net.myns.lib.cutoutcam;
import org.apache.cordova.DroidGap;

import android.os.Bundle;
import android.util.Log;

public class GalleryActivity extends DroidGap {


    private static final String TAG = "GalleryActivity";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
        Log.v(TAG, TAG+" initialised");
    }


}

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.myns.cutoutcamPro"
    android:versionCode="32"
    android:versionName="3.2" >

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" 
        android:hardwareAccelerated="true">
        <activity
            android:name=".CutoutCamProActivity"
            android:configChanges="keyboard|orientation|keyboardHidden"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustPan" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.media.action.IMAGE_CAPTURE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="net.myns.lib.cutoutcam.PreferenceActivity"
            android:label="@string/set_preferences" >
        </activity>
        <activity
            android:name="net.myns.lib.cutoutcam.LoginActivity"
            android:label="Share image" >
        </activity>
        <activity
            android:name="net.myns.lib.cutoutcam.RegisterActivity"
            android:label="Share image" >
        </activity>
        <activity
            android:name="net.myns.lib.cutoutcam.GalleryActivity"
            android:label="All images" >
        </activity>
    </application>

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


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

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

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

</manifest>

GalleryActivity存储在LibraryProject中,不知道这是否有任何区别。

只要将“extend DroidGap”替换为“extends Activity”,就可以开始活动。

有人知道这里出了什么问题吗?

1 个答案:

答案 0 :(得分:2)

找到了答案!

我没有将cordova-1.8.1.jar直接复制到libs目录,而是复制到libs / phonegap-phonegap-ce32a3f / lib / android / cordova-1.8.1.jar

所以请记住:始终将罐子复制到libs文件夹的根目录中!

感谢您的帮助......