如何将 yandex API JAVA 文件包含到 android 项目中

how to include a yandex API JAVA files into an android project

我有包含 JAVA 代码的 Yandex API 文件,我想将其导入到 Android 项目中。我不知道如何将附件包含到一个简单的项目中。

它在 README.MD 文件中声明了以下内容:"Provides a Java wrapper around the Yandex machine translation web service API." 该文件夹有一个 .类路径和 .project 文件。我似乎无法理解。

我尝试了 import/export to/from eclipse w/ gradle ,但这导致我无法摆脱 gradle 版本冲突。所以我尝试手动导入并使用 gradle.build 使用编译文件(“..”)或导入进行链接。

我需要能够调用这组将 return 输出的群集文件。它们位于我的应用程序文件夹中。

我可以简单地获取 java 部分并将它们包含在我的代码中,但我想学习适当的简化形式。

我是新手。所以所有提示都会有所帮助。

Location of the YANDEX API website

Yandex api download zip file

如果你谈论这个项目 https://github.com/rmtheis/yandex-translator-java-api,我认为你不应该使用它。 它没有实现所有 Yandex API 功能,现在也没有开发。

您可以通过 Retrofit 等 REST 库直接调用 Yandex API。

如果你真的需要使用这个库,你可以通过这个构建JAR文件

git clone https://github.com/rmtheis/yandex-translator-java-api
cd yandex-translator-java-api
change src/com/rmtheis/yandtran/ApiKeys.java  
      protected static -> public static
mkdir build
javac -d build -cp "libs/*" -sourcepath src/ src/com/rmtheis/yandtran/detect/Detect.java
cd build
jar -cfv ../yandex-translator-api.jar com/

然后你可以添加 yandex-translator-api.jar 和 libs/json_simple-1.1.jar 到你的项目