gpt4 book ai didi

添加 pdfview 库时 Android Studio 构建失败

转载 作者:行者123 更新时间:2023-11-30 01:18:56 24 4
gpt4 key购买 nike

我有一个工作的 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.

关于添加 pdfview 库时 Android Studio 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37406155/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com