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

terminating with uncaught exception of type std::bad_cast: std::bad_cast #517

Closed
gmaclennan opened this issue Feb 12, 2021 · 3 comments
Closed

Comments

@gmaclennan
Copy link
Member

If Mapeo is failing to start, or quitting on startup, and you see this error in the logs (by running npm run log), then it is likely due to problems with NDK versions in the build.

CMake is used to build native modules for Node (leveldown and sodium) and it seems that CMake has a different mechanism for resolving which NDK version to use to Android.

Android has 3 mechanisms for specifying NDK versions:

  1. android.ndkversion in build.gradle
  2. ANDROID_NDK_HOME environment variable
  3. ANDROID_NDK_ROOT environment variable

Some CI environments can specify one (or more) of these environment variables, and it seems like different tools will prioritize differently which one to use.

In addition, it seems like CMake can ignore all of these, and default to using the latest NDK version installed. If you search through the build logs for references to NDK you should see conflicts of versions e.g.

2021-02-11T21:34:47.5377010Z release|armeabi-v7a :CMake Warning at /Users/runner/Library/Android/sdk/ndk/22.0.7026061/build/cmake/android.toolchain.cmake:453 (message):
2021-02-11T21:34:47.5393400Z release|armeabi-v7a :-- Check for working C compiler: /Users/runner/Library/Android/sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang

shows that CMake is using ndk r22 for the toolchain, even though everything else is configured to use r21. The workaround seems to be to delete all higher NDK versions before trying to build.

A more robust solution would be to find how to specify which NDK version CMake should use.

gmaclennan added a commit that referenced this issue Feb 12, 2021
See #517 for explanation
An update to the Github Action virtual environment added NDK r22,
which CMake uses, ignoring $ANDROID_NDK_HOME.
Solution: Remove NDK r22 and update to latest NDK r21f
gmaclennan added a commit that referenced this issue Apr 29, 2021
* chore: Fix redirect created when a new version is released

Previous link was broken

* chore: Remove untranslated strings from messages (#496)

Reduces memory use and APK size

* chore(CI): Update JDK setup action (#505)

* note to use specific ndk version

* chore: Improve contributor docs (#509)

* chore: Added instructions to build translations and run the Javascript bundler prior to building for Android

* chore: Added instructions for downloading and preparing offline maps wth the needed structure

* chore: Add detailed instructions on how to download maps and add them to phone

* chore: Add note about react-native run-android not opening bundler on all machines

* chore: Add note about com.mapeo changing with different release versions

* chore: Change asar to full flag name

* fix: Localize "Import Config" button (#510)

* fix: Change hardcoded message to intl FormattedMessage

* Add missing string to translations

* chore: prettier

* extract messages

Co-authored-by: Gregor MacLennan <gmaclennan@digital-democracy.org>

* feat: Updated translations (vi, es, po) (#498)

* New translations en.json (Vietnamese)

* New translations en.json (Vietnamese)

* New translations en.json (Vietnamese)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Portuguese, Brazilian)

* New translations en.json (Spanish)

* New translations en.json (Portuguese, Brazilian)

Co-authored-by: Gregor MacLennan <gmaclennan@digital-democracy.org>

* fix: Fix import config button crash (#512)

* fix: Fix import config button crash

* Update version in package-lock

Co-authored-by: luandro <luandro@gmail.com>

* chore: Fix Github CI builds by removing NDK r22 (#516)

See #517 for explanation
An update to the Github Action virtual environment added NDK r22,
which CMake uses, ignoring $ANDROID_NDK_HOME.
Solution: Remove NDK r22 and update to latest NDK r21f

* fix: Write preset tags to observations (#514)

* fix: Add better variable naming and easier to understand logic

* fix: Cleaner and easier to understand logic on updating tags

* fix: Clean redundant code and sort updated value order in preparation for edge cases

* fix: Fix cutoff of text on OnePlus6T phone #502 (#511)

* fix: Fix cutoff of text on OnePlus6T phone #502

Use a custom Text component with fontFamily explicitly set, to work around bug facebook/react-native#15114 (comment)

* Fix implementation of style merging

* fix bugs

* feat: Add French translations

* feat: Add Sranan Tongo translations

* feat: Add Dutch translations

* fix: Update Thai, Khmer & Vietnamese translations

* feat: Updated translations for default configuration (vi, srn)

* Revert "feat: Updated translations for default configuration (vi, srn)"

This reverts commit c267a99.
Install was done using npm@7 which changed the package-lock format and broke the build

* chore: Re-apply c267a99 with correct npm@6 version and lockfile v1

* chore: Prepare release v5.2.0

Co-authored-by: Kira Oakley <kira@eight45.net>
Co-authored-by: luandro <luandro@gmail.com>
Co-authored-by: Digidem Bot <68966934+digidem-bot@users.noreply.github.com>
@ErikSin
Copy link
Contributor

ErikSin commented Sep 14, 2021

@gmaclennan has this been addressed?

@gmaclennan
Copy link
Member Author

In a sense yes. The bug that remains is "Having NDK v22 installed during build-time will cause crash at runtime". The work-around is to delete NDK v22 before building. Android SDK allows several versions of NDK to be installed at the same time, and the build should select the correct version based on Gradle config, but this is not working. This is a bug for people that need to have NDK v22 installed for other projects they are working on.

@gmaclennan
Copy link
Member Author

Going to track in #744, closing here.

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

No branches or pull requests

2 participants