我有一个工作正常的android应用程序,向其中添加了pdfView库。在添加库后,在应用程序内添加了其他功能并在模拟器上运行,构建失败并显示以下跟踪信息:
12:02:39 PM Executing tasks: [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
12:03:58 PM Gradle build finished with 1440 error(s) in 1m 18s 260ms
以下是我所做的更改:
1.我从文件->新建->导入模块中包含了pdflib库
2.在
compile project(':pdfLib')
文件中添加了行build.gradle
。3.使用添加的库添加了一些简单的代码。
在运行时还收到以下异常:
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)
请帮我解决一下这个。
更新:
build.gradle:
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'
}
activity_main.xml
<?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>
我在pdfview中设置pdf的代码:
videoView.setVisibility(View.INVISIBLE);
imageView.setVisibility(View.INVISIBLE);
pdfView.setVisibility(View.VISIBLE);
pdfView.fromFile(new File(mediaPath)).defaultPage(1).enableSwipe(false).load();
最佳答案
只需尝试一下,即可解决您的问题。
- 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.