Akylas / OSS-DocumentScanner

Android document document scanning app
https://www.akylas.fr
MIT License
691 stars 24 forks source link

[BUG] Unable to build using provided instructions #148

Closed ohemelaar closed 5 months ago

ohemelaar commented 6 months ago

Version

master

What platform are you using?

Android

OS Version

Ubuntu 22.04.3 LTS

What happened?

I made some progress to set up the development environment by running a few extra commands:

npm install -g nativescript ts-patch typescript # missing deps
ln -sf $PWD/opencv/android plugin-nativeprocessor/platforms/android/cpp/opencv # fix broken symlink

It starts to build things, but now it fails on an error I don't know how to investigate:

...
Webpack compilation complete. Watching for file changes.
assets by status 6.77 MiB [cached] 52 assets
asset assets/images/filter_color.png 4.61 KiB [emitted] [from: app/assets/images/filter_color.png] [copied]
Entrypoint bundle 3.99 MiB = runtime.js 11.7 KiB vendor.js 3.57 MiB bundle.js 411 KiB
Entrypoint application 13.3 KiB = runtime.js 11.7 KiB application.js 1.55 KiB
cached modules 3.87 MiB (javascript) 12.1 KiB (runtime) [cached] 527 modules
webpack 5.90.3 compiled successfully in 439 ms
cp: no such file or directory: /home/user/projects/OSS-DocumentScanner/plugin-nativeprocessor/platforms/android/cpp/src

I don't know what's supposed to be in this folder, any leads?

Thanks!

Relevant log output

No response

Code of Conduct

farfromrefug commented 6 months ago

@ohemelaar sorry yes that setup is a bit tricky... And you found an issue! for some reason that folder which is a symlink is using absolute symlink. It is now fixed! you can pull

ohemelaar commented 6 months ago

Thanks, I got even further and I feel like I'm almost there :pray:

I found out I also needed to run git submodule init and git submodule update for zxingcpp. After that gradle complained about its version which I switched from 7.6 to 8.2 in platforms/android/gradle/wrapper/gradle-wrapper.properties.

Now I get an error that generateLicenseReport failed:

Error: generateLicenseReport failed
    at ChildProcess.<anonymous> (/home/user/projects/OSS-DocumentScanner/node_modules/@nativescript-community/licenses/scripts/after-prepareNativeApp.js:55:28)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
generateLicenseReport failed
farfromrefug commented 6 months ago

@ohemelaar OK was not sure you were going to need this but lry me explain. the N CLI you arr using foes not officially supports gradle 8 (PR pending). my fork does support it https://github.com/farfromrefug/nativescript-cli I am sorry but you might have to use this :( so fork it, npm install, npm run setup, npm run build. then you need to use the ns generated in the bin dir.

try with that. really sorry you have to do this. hope the PR will come soon

ohemelaar commented 6 months ago

Thanks again for your help. I also added sudo apt install ninja-build openjdk-17-jdk openjdk-17-jre. I might have missed that in the docs of the various tools involved.

Also yarn add ts-loader --dev seemed to fix an error that popped even though it didn't fail immediately.

What I have now though is this:

Could not determine the dependencies of task ':app:buildMetadata'.
Task with path ':android-metadata-generator:jar' not found in project ':app'.

Here's the full logs. logs_output.txt

I'll try to check the docs about android dependencies tomorrow, I'm quite new to this.

farfromrefug commented 6 months ago

@ohemelaar actually really happy you try to build the app. push me to clean thé repo ! your last error I can fix. you can pull it should be fixed!

will update the readme with every hint you gave me. thanks

ohemelaar commented 6 months ago

Thanks, I pulled and could run the build again with a different output:

Error executing Static Binding Generator: Couldn't find '/home/user/projects/OSS-DocumentScanner/build/documentscanner/android/build-tools/sbg-bindings.txt' bindings input file. Most probably there's an error in the JS Parser execution. You can run JS Parser with verbose logging by executing "node '/home/user/projects/OSS-DocumentScanner/build/documentscanner/android/build-tools/jsparser/js_parser.js' enableErrorLogging".

I'll attach the full logs once again in case it helps logs_output.txt

By the way I never mentionned it but I run the command from the README, ns run android --no-hmr --env.devlog. I assume it's still the best way to get up to speed and start testing app changes?

farfromrefug commented 6 months ago

@ohemelaar that s much better. you are close to the end. However that error is tricky to solve :s Could you try rm -fr build/documentscanner/android then build again ? see if it goes through. Also build with ns run android --no-hmr --env.devlog --log debug to see a bit more debug data in case it can help. If it fails you can also share with me the content of /home/user/projects/OSS-DocumentScanner/build/documentscanner/android/build-tools/runSbg.log

Let me know

ohemelaar commented 6 months ago

Okay, I just tried all this here are the logs

logs_output.txt runSbg.log

Then only thing that looks suspicious to me is the line with failed to load gradle properties from "/home/user/projects/OSS-DocumentScanner/build/documentscanner/android/additional_gradle.properties"

farfromrefug commented 6 months ago

@ohemelaar ok might have an idea. Can you go into node_modules/@nativescript/android/framework/build-tools/jsparser/js_parser.js and replace that file with this(rename the file to .js) Let me know if then the build works. Will create a PR on the related repo if it works js_parser.txt

ohemelaar commented 6 months ago

I still get the error, but it looks like the file is the same as the original, even their checksums. Maybe you shared the wrong file?

ohemelaar commented 6 months ago

I just noticed that the package-lock.json isn't committed, maybe we don't have the same dependency versions installed because of this?

farfromrefug commented 6 months ago

@ohemelaar ok let s try this one: js_parser.txt

And i dont use npm, only yarn so no package-lock.json

ohemelaar commented 6 months ago

Right, sorry about the confusion

I still have the same error with this. The logs look the same but I'll still post them: logs_output.txt

To be sure I ran everything after git clean -fdx, so I needed to run yarn and unzip opencv+tessaract again.

farfromrefug commented 6 months ago

weird. it is a Nativescript issue. something is wrong with the generated code from webpack . let me think about it

ohemelaar commented 6 months ago

Out of curiosity I tried with node 18 instead of node 20 and got a completely different output. It seemed to build for longer. What node version do you recommend using?

Error: spawn /home/user/projects/OSS-DocumentScanner/platforms/android/gradlew ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:284:19)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Edit: I can't reproduce this with node 18 since I cleaned the repository again though

farfromrefug commented 6 months ago

I use node 20. we can do something can you share with me the folder build/documentscanner/android/app/SRC/main/assets I will compare it with mine

ohemelaar commented 6 months ago

Okay I'll keep using node 20 then Here's the assets folder: assets.tar.gz

farfromrefug commented 6 months ago

@ohemelaar ok i see the issue there the JS files are not generated, or at least not at the right place It must be some setup issue. This projects uses env variables but the default when they are not defined should be good. could you in the OSS-DocumentScanner search for vendor.js and tell me where it is relatively ?

ohemelaar commented 6 months ago

There's three files named that way, one of them under platforms

./platforms/android/app/src/main/assets/app/vendor.js
./node_modules/autoprefixer/lib/vendor.js
./node_modules/@vue/component-compiler-utils/node_modules/postcss/lib/vendor.js
farfromrefug commented 6 months ago

@ohemelaar ok I sée the issue. that project should use a custom build folder for webpack but it does not and I know why ! I need to publish a package. sorry and thanks for investigating all that !

farfromrefug commented 6 months ago

@ohemelaar i pushed a change. The change is the resolution for @nativescript/webpack in the package.json. Now it is not local but use a hosted tgz on github. With that custom build (waiting for merge) the webpack build should be put in the right directory in build/documentscanner. Let me know if it work. Not 100% sure that resolution works

ohemelaar commented 6 months ago

It works! :tada: I'll try to tinker with some image enhancements algorithms now, thank you very much!!

farfromrefug commented 6 months ago

@ohemelaar awesome can't wait yo see what you can do BTW in cpp folder there is a test CPP app you can use to work on cpp algo without going through the whole app build. I use cmake tools with vscode and simply run cmake: debug