Skip to content

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

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

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

alexander-mai
Copy link
Contributor

@alexander-mai alexander-mai commented Jun 6, 2023

fixes #503

  • replaces TalbotGooday:AndroidPdfViewer with pdfium-android-viewer (a fork of andob) because
  • fixed the problem with duplicate libc++ library on @nativescript/android:8.5
  • generated updated typescript definitions for pdfium-android-viewer

* @nativescript/pdf
  * replaces TalbotGooday:AndroidPdfViewer with pdfium-android-viewer (a fork of andob) because
  * fixed the problem with duplicate libc++ library on @nativescript/android:8.5
  * generated updated typescript definitions for pdfium-android-viewer
@cla-bot cla-bot bot added the cla: yes label Jun 6, 2023
@alexander-mai alexander-mai changed the title https://github.com/NativeScript/plugins/issues/503 [@nativescript/pdf] In NS 8.5, building for Android fails with a "Execution failed for task ':app:mergeDebugNativeLibs'." when using @nativescript/pdf Jun 6, 2023
@NathanWalker
Copy link
Contributor

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

@alexander-mai
Copy link
Contributor Author

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
Copy link
Contributor

insytes commented Jun 15, 2023

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

@alexander-mai thank you 👍🏻

@grigala
Copy link
Contributor

grigala commented Jun 15, 2023

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 #513

@alexander-mai
Copy link
Contributor Author

alexander-mai commented Jun 16, 2023

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
Copy link
Contributor

grigala commented Jun 16, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@NathanWalker NathanWalker merged commit 9b95094 into NativeScript:main Jun 26, 2023
@NathanWalker
Copy link
Contributor

NathanWalker commented Jun 26, 2023

@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
Copy link
Contributor Author

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
Copy link
Contributor

insytes commented Jun 26, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

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