2012-06-19 107 views
1

我有一個PhoneGap的活動,我想通過按下一個按鈕來啓動時的ClassNotFoundException:安卓:試圖啓動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裏面,不知道這是否有什麼區別。

只要我用「extends Activity」替換「extends DroidGap」,就可以啓動活動。

有人知道這裏怎麼了?

+0

GalleryActivity包含哪些包? –

+0

@imrankhan更新了問題 – stoefln

+0

@SimonMacDonald更新了問題 – stoefln

回答

2

找到答案!

,我沒有對科爾多瓦-1.8.1.jar複製到直接libs目錄但庫/ PhoneGap的-的PhoneGap-ce32a3f/lib目錄/安卓/科爾多瓦-1.8.1.jar

所以請記住:總是將jar複製到libs文件夾的根目錄下!

感謝您的幫助......