Unable to import library in Android studio

Asked 2 years ago, Updated 2 years ago, 84 views

I would like to use the Microsoft Translator API in Android studio. So I tried to import this API into the project I created, but it didn't work. Please let me know.

·Environment Android Studio 1.5

First of all, as a method I tried myself,

I thought it was loaded as a library function and I thought it could be implemented, but when I try import, I get an error like an image. Figure 1

Figure 1
Results
From this error, I found an image-like error in the Java file of the library...Figure 2

Figure 2
Result 2

The rebuild did not erase the error. Could you tell me if there was a problem with the library import method and how I can fix this problem?

android android-studio

2022-09-30 16:53

2 Answers

The reason is that a library called json-simple that the library depends on has not been imported.

There is a jar file that contains a library that depends on GitHub, so it will be solved by using it.
https://github.com/boatmeme/microsoft-translator-java-api

Instead of incorporating jar files, I think you can add them to app/build.gradle dependencies.

 dependencies {
    compile'com.memetix:microsoft-translator-java-api:0.6.2'
}


2022-09-30 16:53

There are at least two problems.

  • Problem in Figure 1 - The jar created in the downloaded Microsoft Translator API is not appropriate.Class of this API is not located through the class path.
  • Problems in Figure 2 - Another library used by this API is missing.

If you want to skip the trouble and use it anyway, I think you can eliminate the error by removing the jar file that you are currently trying to import and then executing one of the following A and B proposals.

Proposed A: Leave library dependency resolution to gradle and do not download jar files yourself.
Proposed B: Instead of creating a jar file by yourself, use a jar file with a dependency library provided in advance. - microsoft-translator-java-api-0.6.2-jar-with-dependencies.jar

I can't say for the problem in Figure 1 because I don't know the details of where I downloaded the file and how I made it into a jar file in the procedure of Downloading Microsoft Translator API. However, as far as the capture is concerned, there is a microsoft-transfer-java-api> directory. Perhaps the manifest file does not contain the Class-Path attribute.
(If you would like to resolve this issue, please add details of the steps you have taken to the questionnaire.)

For the issue in Figure 2, you will need to download a separate dependency library and import it into the project.


2022-09-30 16:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.