reneweb / react-native-tensorflow

A TensorFlow inference library for react native
Apache License 2.0
358 stars 59 forks source link

can not load resoure in release apk #25

Open JiangWeixian opened 6 years ago

JiangWeixian commented 6 years ago

I follow the code in your example, it work fine when i react-native run-android

But,when i build in release version。

error, can't load resource

react-native bundle --entry-file App.js --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res/

I use App.js as my entry file not index.js

and genkey, set it in some file

adb install release.apk

success install, but can't load release when i open it

JiangWeixian commented 6 years ago

i change entry file into index.js, i get the same error

aryaminus commented 6 years ago

Same issue. The .pb file is not loaded in release APK and hence error caught when using react-native-camera following takePictureAsync for tfImageRecognition screenshot_20180525-201521

reneweb commented 6 years ago

Are you following this guide to create the apk: https://facebook.github.io/react-native/docs/signed-apk-android.html ? I am asking because you should not need to require to do react-native bundle yourself anymore as it is done when running gradlew assembleRelease. Also, can you try to run react-native run-android --variant=release and see if that works?

aryaminus commented 6 years ago

Followed the Signed APK guide along with react-native run-android --variant=release. No success. The gradle is 3.0.1 if that matters at all

reneweb commented 6 years ago

I have pushed a fix that might help - can you update to version 0.1.8 and see if that helps

aryaminus commented 6 years ago

Same issue with the release variant

aryaminus commented 6 years ago

Do check the repo: https://github.com/aryaminus/nazar where the react-native-tensorflow has been used for real time analysis

leduykhanh commented 6 years ago

same issue here, any solutions?

Isti01 commented 6 years ago

place the graph.pf file in the assets folder

=> android/app/src/main/assets/graph.pb

now you can access it like this:

const tf = new Tensorflow('file://graph.pb');

it works for me. and yes, the file uri is correct file://something

according to this commit: https://github.com/reneweb/react-native-tensorflow/commit/5e3893082995f1a34ce542f575e1e3ef29695302 if(resource.startsWith("file://")) { return loadFromLocal(resource.substring(7));

jpdesignerrio commented 5 years ago

I solve this problem by myself. The solution is in StackOverflow (in Brazilian Portuguese): https://pt.stackoverflow.com/questions/339929/erro-ao-implementar-o-tensorflow-em-react-native/341411#341411