Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why we cannot require for android? #21

Closed
shyam528 opened this issue Jul 11, 2017 · 16 comments
Closed

Why we cannot require for android? #21

shyam528 opened this issue Jul 11, 2017 · 16 comments

Comments

@shyam528
Copy link

Hi,
why require module doesn't support for android?

@wonday
Copy link
Owner

wonday commented Jul 11, 2017

Do you mean source={require("./test.pdf")} ?
As my tested before, require a pdf at ios and android debug version can work, but android release version does not work.
You can use {uri:"bundle-assets://path/to/xxx.pdf"} for android.

@shyam528
Copy link
Author

shyam528 commented Jul 12, 2017

Thanks for the reply . Have to put pdf files in android's asset folder or i can put it anywhere.
{uri:"bundle-assets://path/to/xxx.pdf"}
here from i have pdf in my JS folder , so I have to put that pdf in android folder or i can just give the full path name

@wonday
Copy link
Owner

wonday commented Jul 12, 2017

if you use {uri:"bundle-assets://path/to/xxx.pdf"}
you must put pdf to android folder.
like this:
android/app/src/main/assets/path/to/xxx.pdf

@jkvim
Copy link

jkvim commented Jul 25, 2017

so we should keep two copy of pdf ?

@wonday
Copy link
Owner

wonday commented Jul 25, 2017

@jkvim

In source, you can keep two copy of pdf for android and iOS,
But in built version only one copy in android or iOS app.

If you want to use one copy in source, you can keep android copy, and add it to iOS by reference.

@zdl411437734
Copy link

i use let source = {uri:'bundle-assets://path/to/QXTTV.pdf'}; app crash error msg is /ReactNativeJS: undefined is not a function (evaluating 'l.default.fs.cp(r,n).progress(function(e,r){o.props.onLoadProgress&&o.props.onLoadProgress(e/r),o.setState({progress:e/r})})')

when i use let source = {uri:'https://www.irs.gov/pub/irs-pdf/fw2.pdf',cache:true}; it ok ,what happen? please help me think you!

@zdl411437734
Copy link

@wonday

@wonday
Copy link
Owner

wonday commented Aug 2, 2017

source = {uri:'bundle-assets://path/to/QXTTV.pdf'};

"path/to/QXTTV.pdf" should be real assets path in your source under android/app/src/main/assets/
does it exist?

@wonday wonday closed this as completed Sep 28, 2017
@juanriglos
Copy link

juanriglos commented Oct 4, 2017

it s not working for me, any help?, i'm trying to make it work on android, i tried all the ways,
using:
let source = {uri:"bundle-assets://path/to/pdf-sample.pdf"}
let source = {uri:'bundle-assets://android/app/src/main/assets/pdf/userGuide.pdf'}

and in all ways didnt work,

@wonday
Copy link
Owner

wonday commented Oct 4, 2017

If you have the pdf file at "android/app/src/main/assets/pdf/userGuide.pdf",
you should use let source = {uri:'bundle-assets://pdf/userGuide.pdf'}

@juanriglos
Copy link

i copy the exactly code from documentation i tried also doing let source = {uri:'bundle-assets://pdf/userGuide.pdf'}. My version is "react-native-pdf": "^1.0.5", "react": "15.3.2",
"react-native": "0.36.0". Can i upgrade the version of the pdf maintance the react native version?.
Thanks for the help!!

@wonday
Copy link
Owner

wonday commented Oct 4, 2017

"uri:'bundle-assets://", was added at react-native-pdf ver 1.0.6,
so you should use ver 1.0.6+, but I do not test it with react-native <0.40.0,
I am not sure it can run or not.

you can see the detail release notes at here

@juanriglos
Copy link

thanks for the fast feedback I upgrade to 1.0.6 and the messaje now is "pdf has no proptype for native prop rctpdf.asset of native type string if you havent changed this prop yourself, this usually means that your versions of the native code and javascript code are out of sync. updating both should make this error go away".

If i want to use the uri:FILE:
let source = {uri:"file:////home/me//android-app/android/app/src/main/assets/pdf/userGuide.pdf"}.
How it's works?
Thanks!

@wonday
Copy link
Owner

wonday commented Oct 4, 2017

It can not work. the "android/app/src/main/assets" is not real path in your system.
Dose it work if you use local file? like let source = {uri:"file:////sdcard/xxx/xxx.pdf"}.

@juanriglos
Copy link

i want to add the pdf in the App, it's here "home/me/android-app/js/components/help/userGuide.pdf".
i am trying with many ways, like:
let source = {uri:"file:////home/me/android-app/js/components/help/userGuide.pdf"}
but still now working, i need to make it works with react-native-pdf 1.0.5, because upgrading break up all my App. Thanks for all

@wonday
Copy link
Owner

wonday commented Oct 4, 2017

show the pdf in the App need "uri:'bundle-assets://", but it seems not work.
if you can use let source = {uri:"file:////sdcard/xxx/xxx.pdf"},
You can use react-native-fetch-blob copy the asset pdf to temp path and show it.
for detail, you can see here
or my source code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants