我有一个工作的android应用程序,我已经添加了pdfView库。添加库后,在应用程序中添加其他功能并在模拟器上运行,构建失败并显示以下跟踪:
compile project(':pdfLib')
以下是我所做的更改:
1.我在文件中包含了pdflib库 - >新 - >导入模块
2.在build.gradle
文件中添加了行Caused by: java.lang.UnsatisfiedLinkError: Couldn't load vudroid from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/app.com.blynq.player-2.apk"],nativeLibraryDirectories=[/data/app-lib/app.com.blynq.player-2, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:355)
at java.lang.System.loadLibrary(System.java:525)
at org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
at org.vudroid.pdfdroid.codec.PdfContext.<clinit>(PdfContext.java:13)
at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:31)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
。
3.使用添加的lib添加了一些简单的代码。
在运行时也收到以下异常:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "app.com.blynq.player"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/jackson-annotations-2.7.4.jar')
compile files('libs/jackson-core-2.7.4.jar')
compile files('libs/jackson-databind-2.7.4.jar')
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/jpedal_lgpl.jar')
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
}
请帮我解决一下这个。
更新:
build.gradle:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="app.com.blynq.player.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:src="@drawable/blynq_logo"
/>
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/videoView"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:visibility="invisible"
/>
<com.joanzapata.pdfview.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"/>
</FrameLayout>
activity_main.xml中
videoView.setVisibility(View.INVISIBLE);
imageView.setVisibility(View.INVISIBLE);
pdfView.setVisibility(View.VISIBLE);
pdfView.fromFile(new File(mediaPath)).defaultPage(1).enableSwipe(false).load();
我在pdfview中设置pdf的代码:
try
{
PdfReader reader = null;
int currentPage = 1;
int pageCount = 0;
string destinationFolderPath = string.Format(@"{0}PageImages\{1}", BaseDataPath, Convert.ToString(documentId));
if (!Directory.Exists(destinationFolderPath))
{
Directory.CreateDirectory(destinationFolderPath);
}
reader = new PdfReader(filePath);
reader.RemoveUnusedObjects();
pageCount = reader.NumberOfPages;
string ext = ".png";
for (int i = 1; i <= pageCount; i++)
{
PdfReader reader1 = new PdfReader(filePath);
string destinationFilePath = string.Format(@"{0}/{1}{2}", destinationFolderPath, Convert.ToString(i), ext);
reader1.RemoveUnusedObjects();
Document doc = new Document(reader1.GetPageSizeWithRotation(currentPage));
PdfCopy pdfCpy = new PdfCopy(doc, new FileStream(destinationFilePath, FileMode.Create));
doc.Open();
for (int j = 1; j <= 1; j++)
{
PdfImportedPage page = pdfCpy.GetImportedPage(reader1, currentPage);
//pdfCpy.SetFullCompression();
pdfCpy.AddPage(page);
currentPage += 1;
}
doc.Close();
pdfCpy.Close();
reader1.Close();
reader.Close();
}
}
catch (Exception ex)
{
throw ex;
}
答案 0 :(得分:1)
试试这个,这将解决您的问题。
- Replace your compile project(':pdfLib') with
**'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'** or whatever library you want to add, because adding this type a library, it is
download the library at run time and build the gradle
properly,because adding library manually may occur some path issues
etc.
答案 1 :(得分:0)