简体   繁体   English

如何在Android Studio中使用导入的jar文件中的类

[英]How do I use a class from an imported jar file in Android Studio

I imported a jar file that I created with Eclipse to my Android Studio library but I don't know how to use the classes from it. 我将用Eclipse创建的jar文件导入了Android Studio库,但是我不知道如何使用其中的类。 Imported it here and I'm now trying to use the logarithm class 在这里导入它,我现在尝试使用对数类

I tried to somehow get it with the import word on the beginning of a class but I don't get it to work. 我试图以某种方式在课程开始时使用导入单词来获取它,但是我没有使其起作用。 Sorry I'm a beginner. 对不起,我是初学者。 :p :p

Ok follow this: 确定,请遵循以下步骤:

  1. Put the .jar into the libs folder 将.jar放入libs文件夹
  2. Put compile files('libs/your.jar') is in your build.gradle file (or compile fileTree(dir: 'libs', include: '*.jar') if you are using many jar files) 将编译文件('libs / your.jar')放在build.gradle文件中(或者如果您使用了许多jar文件,则编译fileTree(dir:'libs',include:'* .jar'))
  3. Do a clean build (you can probably do this fine in Android Studio, but to make sure I navigated in a terminal to the root folder of my app and typed gradlew clean. If this does not work then use the terminal tab and do this: gradlew clean . 做一个干净的构建(您可能可以在Android Studio中做到这一点,但是要确保我在终端中导航到应用程序的根文件夹并键入gradlew clean。如果这样不起作用,请使用终端选项卡并执行以下操作: gradlew clean

    Hope it helps!!! 希望能帮助到你!!!

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

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