I am trying to implement rendering/viewing pdf file by using PdfRenderer API.So I have created a assets folder in res(resources) which has a pdf file named sample.pdf. The following is what my build.gradle file looks like.
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"
}
}
And this is my Manifest file.
<?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.
I am new to programming so any help or suggestion is appreciated.Thank you.
The /assets
folder goes under /main
, not under /res
. Your build error is basically saying it found something it shouldn't have in your /res
folder.