cake-tech / cake_wallet

The open source repository for Cake Wallet, a noncustodial multi-currency wallet, and Monero.com, a noncustodial Monero-only wallet. Need help? Check out https://guides.cakewallet.com
https://cakewallet.com
MIT License
684 stars 182 forks source link

Building for Android failed (an issue with some Monero library) #1101

Closed LeoBlackCat closed 1 year ago

LeoBlackCat commented 1 year ago

Hey y'all, I started working on Cake Wallet source code, set up a clean ubuntu console virtual machine, installed Android SDK & Build Tools & NDK, latest Flutter 3.10 distribution, latest sources from the GitHub, so everything according to instructions howto-build-android.md & configure_cake_wallet_android.sh. Haven-only version (source ./app_env.sh haven) builds successfully (with some minor issues), I can install and test an app on my Android smartphone. Building full version (source ./app_env.sh cakewallet) failed with the following error message:

leo@ubuntu-s-2vcpu-8gb-160gb-intel-sfo3-01:/opt/android/cake_wallet$ flutter build apk --release
The plugin `cw_monero` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding.
Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding:
https://flutter.dev/go/android-plugin-migration.

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 1132 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2844 bytes (99.8% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cw_monero:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process /home/leo/android-sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /opt/android/cake_wallet/cw_monero/android/.cxx/cmake/release/x86_64 cw_monero}
  ninja: Entering directory `/opt/android/cake_wallet/cw_monero/android/.cxx/cmake/release/x86_64'

  ninja: error: '../../../../../../cw_shared_external/ios/External/android/x86_64/lib/monero/libunbound.a', needed by '/opt/android/cake_wallet/build/cw_monero/intermediates/cmake/release/obj/x86_64/libcw_monero.so', missing and no known rule to make it

* 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 2m 18s
Running Gradle task 'assembleRelease'...                          139.0s
Gradle task assembleRelease failed with exit code 1

I doublechecked building monero part of sources (./build_monero.sh) — it runs without any errors (I also built and installed libunbound, which was necessary for monero). Any ideas on it?

leo@ubuntu-s-2vcpu-8gb-160gb-intel-sfo3-01:~$ flutter doctor

┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available!                  │
│                                                         │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on Ubuntu 20.04.4 LTS 5.4.0-163-generic, locale C.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 2 categories.

P.S. It might be a problem that I am building for console Ubuntu, not for a desktop, and therefore I don't have Android Studio installed (I'm not sure it's possible on console)

LeoBlackCat commented 1 year ago

Hey guys, I made it! Just copied libunbound.a to cw_shared_external/ios/External/android/x86_64/lib/monero/ directory