简体   繁体   English

如何在 Android 项目中使用 Solana.kt 库?

[英]How do I use Solana.kt library in Android project?

I'm trying to import Solana.kt library - https://github.com/ajamaica/Solana.kt into my android project, so I could try creating solana wallet/sending tokens.我正在尝试将 Solana.kt 库 - https://github.com/ajamaica/Solana.kt导入到我的 android 项目中,因此我可以尝试创建 solana 钱包/发送令牌。 I'm noob, so I can't figure out how do I go exactly adding library into the project and then how to I use it?我是菜鸟,所以我不知道如何将库准确地添加到项目中,然后如何使用它? (For example from my MainActivity I want to click button to create wallet). (例如,从我的 MainActivity 我想单击按钮来创建钱包)。 Library code is like this -库代码是这样的 - 在此处输入图像描述

So my main questions are所以我的主要问题是

  • how to import it properly?如何正确导入? (since there is no direct gradle "implement" option) (因为没有直接的 gradle“实现”选项)
  • how do I call library method from my MainActivity?如何从我的 MainActivity 调用库方法?

设置.gradle

build.gradle 第 1 部分 build.gradle 第 2 部分 build.gradle 第 3 部分 build.gradle 第 4 部分 Thank you for your insights.感谢您的见解。

I think it helps to include the local SDK to your own project:我认为将本地 SDK 包含到您自己的项目中会有所帮助:

  1. Copy solana folder to your main project folder ( ctrl+c & ctrl+v )solana文件夹复制到您的主项目文件夹( ctrl+c & ctrl+v
  2. Open settings.gradle file and put this piece of code打开 settings.gradle 文件,把这段代码

include ':app', ':solana'

project(':solana').projectDir = new File(settingsDir, 'solana')

  1. After that open the app build.gradle file and put this:之后打开应用程序build.gradle文件并输入:

implementation project(path: ':solana')

If your version of configure files are suitable with sdk files, this should work如果您的配置文件版本适用于 sdk 文件,这应该可以

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM