gpt4 book ai didi

java - 如何解决pdf文件的Prolog中不允许内容的错误?

转载 作者:行者123 更新时间:2023-12-02 03:31:41 25 4
gpt4 key购买 nike

我正在尝试使用 PdfRenderer API 来实现渲染/查看 pdf 文件。因此我在 res(resources) 中创建了一个 Assets 文件夹,其中有一个名为 example.pdf 的 pdf 文件。以下是我的 build.gradle 文件的样子。

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "org.inevitablesol.com.demopdf"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}

//adding aaptOptions
android {
aaptOptions {
noCompress "pdf"
}
}

这是我的 list 文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.inevitablesol.com.demopdf">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

When I build my project I get the following errors: Error:(1, 1) Error: Content is not allowed in prolog. :app:mergeDebugResources FAILED Error:Execution failed for task ':app:mergeDebugResources'.

C:\Users\AndroidNewBee\AndroidStudioProjects\DemoPdf\app\src\main\res\assets\sample.pdf:1:1: Error: Content is not allowed in prolog. Build Failed.

我是编程新手,因此感谢任何帮助或建议。谢谢。

最佳答案

/assets 文件夹位于 /main 下,而不是 /res 下。您的构建错误基本上是说它在您的 /res 文件夹中找到了不应该包含的内容。

关于java - 如何解决pdf文件的Prolog中不允许内容的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38008135/

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