NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
189 stars 107 forks source link

[@nativescript/pdf] In NS 8.5, building for Android fails with a "Execution failed for task ':app:mergeDebugNativeLibs'." when using @nativescript/pdf #505

Closed alexander-mai closed 1 year ago

alexander-mai commented 1 year ago

fixes https://github.com/NativeScript/plugins/issues/503

NathanWalker commented 1 year ago

@alexander-mai nice work, were there any TS changes needed from the gradle package updates?

alexander-mai commented 1 year ago

No, there were no TS changes. I tested on my personal apps and the typescript demo without any problem.

I was not able to test against the angular-demo because I got the error on nx run demo-angular:ios:

npm ERR! code 1
npm ERR! path <PROJECT_PATH>/dist/packages/detox
npm ERR! command failed
npm ERR! command sh -c node postinstall.js
npm ERR! node:internal/modules/cjs/loader:1078
npm ERR!   throw err;
npm ERR!   ^
npm ERR! 
npm ERR! Error: Cannot find module '<PROJECT_PATH>/dist/packages/detox/postinstall.js'
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:920:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:23:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }
npm ERR! 
npm ERR! Node.js v18.16.0

npm ERR! A complete log of this run can be found in:
npm ERR!     <HOME_DIR>/.npm/_logs/2023-06-12T05_19_11_668Z-debug-0.log
Unable to install dependencies. Make sure your package.json is valid and all dependencies are correct. Error is: Command npm failed with exit code 1
Done.
insytes commented 1 year ago

fixed the problem with duplicate libc++ library on @nativescript/android:8.5

@alexander-mai thank you 👍🏻

grigala commented 1 year ago

No, there were no TS changes. I tested on my personal apps and the typescript demo without any problem.

I was not able to test against the angular-demo because I got the error on nx run demo-angular:ios:

npm ERR! code 1
npm ERR! path <PROJECT_PATH>/dist/packages/detox
npm ERR! command failed
npm ERR! command sh -c node postinstall.js
npm ERR! node:internal/modules/cjs/loader:1078
npm ERR!   throw err;
npm ERR!   ^
npm ERR! 
npm ERR! Error: Cannot find module '<PROJECT_PATH>/dist/packages/detox/postinstall.js'
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:920:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:23:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }
npm ERR! 
npm ERR! Node.js v18.16.0

npm ERR! A complete log of this run can be found in:
npm ERR!     <HOME_DIR>/.npm/_logs/2023-06-12T05_19_11_668Z-debug-0.log
Unable to install dependencies. Make sure your package.json is valid and all dependencies are correct. Error is: Command npm failed with exit code 1
Done.

This error is not related to the PDF plugin. It is rather an issue of that detox plugin. Had the same error while doing https://github.com/NativeScript/plugins/pull/513

alexander-mai commented 1 year ago

This error is not related to the PDF plugin. It is rather an issue of that detox plugin. Had the same error while doing #513

Hello @grigala, I realize it has nothing to do with the PDF plugin. I just wanted to inform that I couldn't test my changes with the Angular demo app. But thanks for the help in solving the problem.

grigala commented 1 year ago

This error is not related to the PDF plugin. It is rather an issue of that detox plugin. Had the same error while doing #513

Hello @grigala, I realize it has nothing to do with the PDF plugin. I just wanted to inform that I couldn't test my changes with the Angular demo app. But thanks for the help in solving the problem.

You should be able to test it, just remove https://github.com/NativeScript/plugins/blob/main/apps/demo-angular/package.json#L18 line locally to get rid of that errror. 😉

alexander-mai commented 1 year ago

Thank you for the tip @grigala. Now I have tested my changes on typescript and angular demo with success.

I hope it could be merged soon @NathanWalker.

NathanWalker commented 1 year ago

Thank you and sorry for delay @alexander-mai we’ll get this published by Monday.

NathanWalker commented 1 year ago

@alexander-mai we need to revert this - looks like original plugin works fine but the changes here don't build at all? Results in build gradle error:

Gradle build...
         + setting applicationId
         + applying user-defined configuration from /Users/nstudio/Documents/github/NativeScript/plugins/tools/assets/App_Resources/Android/app.gradle
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/nstudio/Documents/github/NativeScript/plugins/node_modules/@nativescript/core/platforms/android/core.aar
         + adding aar plugin dependency: /Users/nstudio/Documents/github/NativeScript/plugins/node_modules/@nativescript/core/platforms/android/widgets-release.aar

Build file '/Users/nstudio/Documents/github/NativeScript/plugins/apps/demo/platforms/android/app/build.gradle' line: 586
A problem occurred configuring project ':app'.

Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1.
alexander-mai commented 1 year ago

I can't reproduce the problem. I can easily launch the demo apps of the plugin repo (Typescript and Angular) for IOS and Android. The build of my app also works without errors with the modified plugin.

I got some build errors with other plugins (contacts, camera, background-http).

insytes commented 1 year ago

FWIW these are the changes I use to overcome this problem

// App_Resources/Android/app.gradle
android {
  //..
  packagingOptions {
    pickFirst 'lib/x86/libc++_shared.so'
    pickFirst 'lib/x86_64/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    pickFirst 'lib/arm64-v8a/libc++_shared.so'
  }
  //..
}
alexander-mai commented 1 year ago

Because packagingOptions.pickFirst is deprecated (https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/PackagingOptions#pickFirst(kotlin.String)), I switched to packagingOptions.jniLibs.pickFirsts

This worked fine for me @insytes.

alexander-mai commented 1 year ago

Can you recheck the problem @NathanWalker? Like I wrote, I can't reproduce it. But we need a solution for this problem.

I am using the fix without any problem on packaging the module or building my apps.