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

build your own android aar lib or else will lookup failed #26

Open
weishirongzhen opened this issue Sep 15, 2021 · 28 comments
Open

build your own android aar lib or else will lookup failed #26

weishirongzhen opened this issue Sep 15, 2021 · 28 comments

Comments

@weishirongzhen
Copy link
Owner

weishirongzhen commented Sep 15, 2021

Because official lib build flag in CmakeLists.txt set(CMAKE_CXX_VISIBILITY_PRESET hidden), that will cause android exception when dart ffi lookup function.

Please refer to My other repo to run full demo,
also, replace you own build to ensure safety.
build step: follow Official build step to prepare your build env , then change

 set(CMAKE_CXX_VISIBILITY_PRESET hidden)

to

 set(CMAKE_CXX_VISIBILITY_PRESET default)

build project, replace your own output in My other repo.

@weishirongzhen weishirongzhen pinned this issue Sep 15, 2021
@sylvestrevgen
Copy link

I have an issue with dart ffi and lookup function, my app is crashed on start. Can you tell, please, what should I do with this?

@weishirongzhen
Copy link
Owner Author

I have an issue with dart ffi and lookup function, my app is crashed on start. Can you tell, please, what should I do with this?

Any log? And please refer to README.md , there may some way to solved your issue.

@weishirongzhen
Copy link
Owner Author

Now Android Lib are extract to github package.

repositories {
        google()
        jcenter()
        maven {
            url = uri("https://maven.pkg.github.com/weishirongzhen/wallet-core")
            credentials {
                username = "weishirongzhen"
                password = "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" // GH token for only allow read package
            }
        }
    }

then

implementation "com.weishirongzhen:wallet-core:2.6.20"

@winterdl
Copy link

winterdl commented Oct 7, 2021

How to build the android lib or ios framework from the trust wallet core, what should we modify the code of trust wallet core repo to build succesful for flutter, thank you.

@weishirongzhen
Copy link
Owner Author

How to build the android lib or ios framework from the trust wallet core, what we should modify the code of trust wallet core repo to build succesful for flutter, thank you.

build step please refer to this link https://developer.trustwallet.com/wallet-core/developing-the-library/building

and for android, only need to do is modify CMakeLists.txt and

change set(CMAKE_CXX_VISIBILITY_PRESET hidden) to set(CMAKE_CXX_VISIBILITY_PRESET default)

@RayOkaah
Copy link

How to connect to network?

@weishirongzhen
Copy link
Owner Author

How to connect to network?

wallet-core only handle local things, create wallet, sign transaction etc, your can broadcast your sign output to any network you like.

@RayOkaah
Copy link

Thanks. Please point me to any resource I can read up on broadcasting on a network. Thanks for the work.

@weishirongzhen
Copy link
Owner Author

Thanks. Please point me to any resource I can read up on broadcasting on a network. Thanks for the work.

For ETH below link may help

https://infura.io/product/ethereum

https://docs.etherscan.io/

@sylvestrevgen
Copy link

Hello. How can I use this package? I ask this, cause before, you wrote in README that we need to build trustwallet core and move to flutter plugin. But now, you removed this steps from README.md. So, I can clone this repo and just use without any building?

@weishirongzhen
Copy link
Owner Author

yes, if you want to use in your own project
just add this in your yaml

 flutter_trust_wallet_core:
    git:
      url: https://github.com/weishirongzhen/flutter_trust_wallet_core_lib_include.git

@sylvestrevgen
Copy link

Okay. But how it works? We are building our wallet app and цe're worried about security. Cause we don't know what is inside android and ios builds. Maybe, mining?)) Sorry, it is joke. But we are a little worried.

@sylvestrevgen
Copy link

But you have done an excellent work and we really want to use your plugin.

@weishirongzhen
Copy link
Owner Author

weishirongzhen commented Nov 22, 2021

if you are worry , you can build your own lib to use.
for android only need to change CMakeList.txt line 14 , from "hidden" to "default", and follow the official build step.
for iOS, nothing need to change, just follow the official build step.
and then replace your lib in to project.

@sylvestrevgen
Copy link

So, for our own builds, we need just move android build to android/libs/....aar, and ios - ios/frameworks/...? Thats all?

@weishirongzhen
Copy link
Owner Author

yep, that's all you need to do

@sylvestrevgen
Copy link

Understood, thank you so much for information. And thank you for all your work. Please, keep going your excellent work.

@weishirongzhen
Copy link
Owner Author

weishirongzhen commented Nov 22, 2021

Understood, thank you so much for information. And thank you for all your work. Please, keep going your excellent work.

Thanks, there still are lots of code to do, I'm busy at other flutter project, this project are quite slow progress, but will keep update.

@sylvestrevgen
Copy link

Hello. I try to launch on Android and its crashed. I built trustwalletcore.aar from wallet-core repo, put in /android/libs but error occured. Do you know how can I fix this problem, Also, trying to use repo flutter_trust_wallet_core_include_lib, but the same error
Screenshot 2021-12-21 at 16 18 40
.

@weishirongzhen
Copy link
Owner Author

Hello. I try to launch on Android and its crashed. I built trustwalletcore.aar from wallet-core repo, put in /android/libs but error occured. Do you know how can I fix this problem, Also, trying to use repo flutter_trust_wallet_core_include_lib, but the same error Screenshot 2021-12-21 at 16 18 40 .

Didn't try this project run on x86 platform, try use arm device to run it.

@hnord-vdx
Copy link

@weishirongzhen Do you know why does it only affect the android build?

@weishirongzhen weishirongzhen changed the title Lib include in repository build your own android aar lib Apr 2, 2022
@weixuefeng
Copy link

weixuefeng commented Jul 19, 2023

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen

@weishirongzhen
Copy link
Owner Author

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen
不需要

@weixuefeng
Copy link

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen
不需要

好的,多谢。可以帮看看这个问题吗?
trustwallet/wallet-core#3319

我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

@weishirongzhen
Copy link
Owner Author

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen
不需要

好的,多谢。可以帮看看这个问题吗? trustwallet/wallet-core#3319

我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

请提供下具体的代码调用过程

@weixuefeng
Copy link

weixuefeng commented Jul 22, 2023

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen
不需要

好的,多谢。可以帮看看这个问题吗? trustwallet/wallet-core#3319
我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

请提供下具体的代码调用过程

@weishirongzhen
my build command is:

./tools/install-dependencies
./tools/install-rust-dependencies
./tools/install-wasm-dependencies

./tools/generate-files ios
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
 make -Cbuild && ./tools/ios-build && ./tools/ios-xcframework

then i got

./swift/build/WalletCore.xcframework/
./swift/build/SwiftProtobuf.xcframework/

then i import WalletCore.xcframework & SwiftProtobuf.xcframework to my ios project, all code is:

//
//  ContentView.swift
//  wallet
//
//

import SwiftUI
import WalletCore
struct ContentView: View {
    var json = """
                {"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"5fe1054ca4ca68c5f8ee1346cd062239"},"ciphertext":"ae7db4237ec6913241dcf7bcfb6e06671ae381906a2866b04771082ed0204ac4","kdf":"scrypt","kdfparams":{"dklen":32,"n":16384,"p":4,"r":8,"salt":""},"mac":"9ed6e105ebcc39ba38706166a24f03ebfa153fc41bc028418dafb08518d6ebae"},"id":"b4c58a86-f609-4c12-88bd-666cc2ee73be","name":"name","type":"private-key","version":3}
""";
    var body: some View {
        
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text("Hello, world!")
            Button("click") {
                
         
                print(SegwitAddress.isValidString(string: "bc1qyd9ky0n2dh8nggk8m4thllh0qh0w2ea2asvtl5"))
                print(SegwitAddress.isValidString(string: "1CFx8Qvd3ioDHYWHJMSMNeredCCkW96wAA"))
                let storedKey = StoredKey.importJSON(json: json.data(using: String.Encoding.utf8)!)!
             
                let privatekey = storedKey.decryptPrivateKey(password: "password".data(using: String.Encoding.utf8)!)
                
                
                print(privatekey?.hexString)
            }
        }
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

then i click click, i can not decrypt keystore, privateKeyHex is nil.
but when i use official package, i can decrypt then same keystore, so , is there have some problem about my build flow?

@weishirongzhen
Copy link
Owner Author

I think you can try with below two step

./bootstrap.sh
./tools/ios-xcframework

then copy new WalletCore.xcframework and SwiftProtobuf.xcframework to you project

@weixuefeng
Copy link

weixuefeng commented Jul 26, 2023

i got nil too... Did you make it? @weishirongzhen

@weishirongzhen weishirongzhen changed the title build your own android aar lib build your own android aar lib or else will lookup failed Apr 19, 2024
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

6 participants