10-02 05:36:39.589: E/dalvikvm(2570): Could not find class 'org.bouncycastle.cms.CMSEnvelopedData',
referenced from method com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj
logcat显示这种错误,我一直在谷歌搜索,仍然找不到解决方案。
这是源代码:
MainActivity.java
import java.io.FileOutputStream;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
GenerarPDF();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void GenerarPDF()throws Exception{
Document document = new Document();
String file = Environment.getExternalStorageDirectory().getPath() + "/Hello.pdf";
PdfWriter.getInstance(document,new FileOutputStream(file));
document.open();
Paragraph p = new Paragraph("Hello PDF");
document.add(p);
document.close();
}
}
这是我的 manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.samplepdf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
谁能指出这个问题的解决方案?