Errors with Manual Android Native Build

0
Hey guys,   I’m attempting to build an android native app manually, following the steps provided in the documentation here, Building an Android App with Android Studio, and it’s failing with the below error:   More than one file was found with OS independent path 'lib/armeabi-v7a/libfbjni.so'.   After some research, it appears that you can force the app to select the first option of these files that appears in the packingOptions of the build.gradle (app) file, something like this:   packagingOptions { pickFirst '**/libfbjni.so' pickFirst '**/libjsc.so' pickFirst '**/libc++_shared.so' }  This fixes the build error, however during runtime as soon as I open the app it immediately fails and closes with the following error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mendix/mendixnative/error/ErrorHandlerToRedBoxMapperKt$mapErrorHandlerToRedBox$1;   Anyone else experienced this and worked through it? Additional Notes Local version of npm: 8.7.0 (Yes I used npm install --legacy-peer-deps per the documentation) Android Studio version: Chipmunk Build 2021.2.1 Patch #2 We’ve tried building this using AppCenter and the native builder but we’re getting errors there too:   FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:mergeAppstoreReleaseNativeLibs'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > More than one file was found with OS independent path 'lib/armeabi-v7a/libfbjni.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 5m 37s Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.5/***guide/command_line_interface.html#sec:command_line_warnings 523 actionable tasks: 497 executed, 26 up-to-date Error: /Users/runner/work/1/s/android/gradlew failed with return code: 1 at ChildProcess.<anonymous> (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:920:16) at Socket.<anonymous> (internal/child_process.js:351:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:509:12) ##[error]Error: /Users/runner/work/1/s/android/gradlew failed with return code: 1 Any pointers would be much appreciated!
asked
2 answers
1

Hi, in the build.gradle from the project nativeTemplate you can add below to use the react native from the nodes module folder: 

https://stackoverflow.com/questions/74333787/react-native-2-files-found-with-path-lib-arm64-v8a-libfbjni-so-from-inputs

exclusiveContent {
     // We get React Native's Android binaries exclusively through npm,
     // from a local Maven repo inside node_modules/react-native/.
     // (The use of exclusiveContent prevents looking elsewhere like Maven Central
     // and potentially getting a wrong version.)
     filter {
           includeGroup "com.facebook.react"
     }
     forRepository {
           maven {
           // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
              url "$rootDir/../node_modules/react-native/android"
           }
     }
}

 
answered
1

Hey Austin,

I am not sure that I can solve your issue or not, but when I faced an issue like this, I resolved it by the following way,

Please check that your theme file contains the following files,

I was also getting this issue, and my issue was resolved by adding these 4 files,

You can see the directory  of the folder,

 

Hope it helps!

answered