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

Futter Build Fails > More than one file was found with OS independent path 'lib/x86/libc++_shared.so' #210

Closed
ArjunNagraj opened this issue Mar 22, 2021 · 22 comments · Fixed by #218

Comments

@ArjunNagraj
Copy link

ArjunNagraj commented Mar 22, 2021

Flutter build fails after adding flutter_vlc_player

environment:
sdk: ">=2.2.2 <3.0.0"

Flutter 1.22.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aafb3a8b9 (4 months ago) • 2020-11-13 09:59:28 -0800
Engine • revision 2c956a31c0
Tools • Dart 2.10.4

  • What went wrong:
    Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

More than one file was found with OS independent path 'lib/x86/libc++_shared.so'

The Stack Trace On Debug With Gradle.

Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

More than one file was found with OS independent path 'lib/x86/libc++_shared.so'

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
    at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    Caused by: com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'lib/x86/libc++_shared.so'
    at com.android.builder.merge.StreamMergeAlgorithms.lambda$acceptOnlyOne$2(StreamMergeAlgorithms.java:75)
    at com.android.builder.merge.StreamMergeAlgorithms.lambda$select$3(StreamMergeAlgorithms.java:100)
    at com.android.builder.merge.IncrementalFileMergerOutputs$1.create(IncrementalFileMergerOutputs.java:86)
    at com.android.builder.merge.DelegateIncrementalFileMergerOutput.create(DelegateIncrementalFileMergerOutput.java:61)
    at com.android.build.gradle.internal.transforms.MergeJavaResourcesTransform$1.create(MergeJavaResourcesTransform.java:386)
    at com.android.builder.merge.IncrementalFileMerger.updateChangedFile(IncrementalFileMerger.java:221)
    at com.android.builder.merge.IncrementalFileMerger.mergeChangedInputs(IncrementalFileMerger.java:190)
    at com.android.builder.merge.IncrementalFileMerger.merge(IncrementalFileMerger.java:77)
    at com.android.build.gradle.internal.transforms.MergeJavaResourcesTransform.transform(MergeJavaResourcesTransform.java:419)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
    ... 31 more

@mitchross
Copy link
Contributor

can you share a sample git repo?

@ArjunNagraj
Copy link
Author

Sure will create an app with the dependencies and share git repo to it. Thanks a lot :)

@ArjunNagraj
Copy link
Author

Hi @mitchross please find the link to a sample git repo

https://github.com/TudoTech/flutter_vlc_test

@solid-yuriiprykhodko
Copy link
Collaborator

Hey! I think I've encountered a similar error before. It's caused by two packages depending on a single lib binary.
This isn't something that we can resolve at package level.

You'll need to add the following lines to your application's build.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'
    }
}

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko thanks though I am sure this will work I am only cautious of the effects it may cause at runtime and not knowing which the other plugin may be is difficult to plan a regression test.
Please let me know if by any chance u can tell what loads this library while using the VLC plugin,

@solid-yuriiprykhodko
Copy link
Collaborator

solid-yuriiprykhodko commented Mar 24, 2021

This plugin doesn't load libc++_shared directly. It's coming from the libvlc, which in its turn loads the lib as part of Android NDK version >=13.

It appears the VLC team uses the exact same approach for the Android VLC app:
https://code.videolan.org/videolan/vlc-android/-/blob/master/application/app/build.gradle#L20

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko
After adding these options thr build succeeds but there is a runtime error crashing the app.
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'
}

Run time error
E/VLC/LibVLC(11833): Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/com.example.vlc_tudo_test-3480LOmuDitc7BzWn3tmxA==/lib/arm64/libvlc.so"...

@solid-yuriiprykhodko
Copy link
Collaborator

I can't seem to reproduce the error with the crash - the video surface fails to load, but I'm still getting the audio.
Could you please update the sample app you've shared to reliably reproduce the crash?

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko have pushed the latest code....can u please check it now....The device i am running the debug with his a
Redmi Note Android : 8.1

@solid-yuriiprykhodko
Copy link
Collaborator

Checked out the example - can't repro the crash, but the live video doesn't play for me.
Device: Huawei P40
Android: 10.1

It seems to be a mediacodec issue:

2021-03-25 19:31:06.926 6647-9593/com.example.vlc_tudo_test E/NdkMediaCodec: sf error code: -38
...
2021-03-25 19:31:06.934 1908-2570/? I/DeviceStateService: app: com.example.vlc_tudo_test pid: 6647 stop mediacodec.
...
2021-03-25 19:31:06.955 6647-9580/com.example.vlc_tudo_test D/SurfaceUtils: disconnecting from surface 0x76d6279010, reason disconnectFromSurface
...
2021-03-25 19:31:57.527 6647-9605/com.example.vlc_tudo_test E/VLC: [00000077776aa210/2585] libvlc stream: Failed to open rtmp://139.59.44.158/live/app: I/O error


@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko thanks a lot for checking....i do not know why its crashing in my build. Will it help if i can share the debug apk from my build.
The RTMP stream failed to load as the live stream was not active.

@solid-yuriiprykhodko
Copy link
Collaborator

@ArjunNagraj Let's try the APK -- might be a problem with build tools version.

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko Please find appended below the link to download the file.
https://we.tl/t-otGoOKxOfe
Thanks a load 🙏.

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko please let me know if you were able to download the APK.

@solid-yuriiprykhodko
Copy link
Collaborator

@solid-yuriiprykhodko please let me know if you were able to download the APK.

Hi! Just tried out your APKs - crash does get reproduced.
You didn't mention that the problem appeared on release builds - when I tried doing a release build locally, it crashed for me, too.

My guess is that this happens due to code shrinking - we'll need to experiment with ProGuard rules to make sure any necessary libs don't get excluded.

@solid-yuriiprykhodko
Copy link
Collaborator

@ArjunNagraj Added instructions to fix the build issues -- see the README.md on latest master.

@ArjunNagraj
Copy link
Author

Wow @solid-yuriiprykhodko u r awesome 😎🎉🙏
Thanks a load

@ArjunNagraj
Copy link
Author

I am still facing this issue....
E/VLC/LibVLC(30984): Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/com.example.vlc_tudo_test-5Mt0g7qJuLm73HmKr8-19A==/lib/arm64/libvlc.so"...

Have updated the repo with latest code....i added the progaurd to debug build as well as in my case the debug build was also crashing.

@solid-yuriiprykhodko
Copy link
Collaborator

@ArjunNagraj That's strange, the crash doesn't appear on debug at all for me.
Could you please update the example app you've shared?

@solid-yuriiprykhodko
Copy link
Collaborator

@ArjunNagraj That's strange, the crash doesn't appear on debug at all for me.
Could you please update the example app you've shared?

Oh, I see you've already done that. Looking at it now.

@solid-yuriiprykhodko
Copy link
Collaborator

@ArjunNagraj The app runs absolutely fine for me, on debug and release, when I build it from the example app you've shared. Could you please share the APKs once more?

@ArjunNagraj
Copy link
Author

@solid-yuriiprykhodko I know not sure it crashes in my build.
Since the debug apk is quite large I have uploaded it on wetransfer, please find appended below the link for the same:
https://wetransfer.com/downloads/24fd5ce2db99c62d26e8e8aa094d6eb420210330173239/29a909510cde10bccb6ffb438582ed7920210330173304/19ad0d

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

Successfully merging a pull request may close this issue.

3 participants