0

PdfRenderer API を使用して、pdf ファイルのレンダリング/表示を実装しようとしています。そのため、res(resources) に、sample.pdf という名前の pdf ファイルを持つ assets フォルダーを作成しました。以下は、私の 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"
    }
}

これが私のマニフェストファイルです。

<?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>

プロジェクトをビルドすると、次のエラーが表示されます: エラー:(1, 1) エラー: コンテンツはプロローグでは許可されていません。:app:mergeDebugResources FAILED エラー: タスク ':app:mergeDebugResources' の実行に失敗しました。

C:\Users\AndroidNewBee\AndroidStudioProjects\DemoPdf\app\src\main\res\assets\sample.pdf:1:1: エラー: プロローグではコンテンツを使用できません。ビルドに失敗しました。

私はプログラミングが初めてなので、助けや提案をいただければ幸いです。

4

1 に答える 1

2

/assetsフォルダは/mainではなく の下にあります/res。あなたのビルドエラーは、基本的に、/resフォルダーにあるべきではないものが見つかったと言っています。

于 2016-06-24T07:54:59.423 に答える