[英]How to run jar file within Android Studio?
I have a jar file of java classes. 我有一个java类的jar文件。 I want to create an apk of my jar file.
我想创建一个我的jar文件的apk。 I know how to add libs folder into my android project, but I do not know how to make connections.
我知道如何将libs文件夹添加到我的android项目中,但我不知道如何建立连接。 I need to refer to my jar file in MainActivity.java, as well as in AndroidManifest.xml?
我需要在MainActivity.java和AndroidManifest.xml中引用我的jar文件? What should I write in these two files?
我应该在这两个文件中写什么? Indeed, I spent good time googling for an answer and reading posts on stackoverflow and others, but I did not find the specific answer for my question.
事实上,我花了很多时间谷歌搜索回答和阅读stackoverflow和其他人的帖子,但我没有找到我的问题的具体答案。
I hope you can help me. 我希望你能帮助我。 Lina
丽娜
Copy and paste the .jar file into libs folder of your Android Project. 将.jar文件复制并粘贴到Android项目的libs文件夹中。 Then open your gradle.build(Module:app) and then you can see .jar in
dependencies{}
然后打开你的gradle.build(Module:app)然后你就可以在
dependencies{}
看到.jar
Now you can use classes which are reside in .jar file. 现在您可以使用驻留在.jar文件中的类。 Hope this helps you...
希望这可以帮助你......
Copy the .jar
file to clipboard then add it to libs folder. 将
.jar
文件复制到剪贴板,然后将其添加到libs文件夹。
To see libs folder in the project, choose the project from the combobox above the folders. 要查看项目中的libs文件夹,请从文件夹上方的组合框中选择项目。 Then right click on the
.jar
file, and click "add as a library" then choose a module then press ok. 然后右键单击
.jar
文件,然后单击“添加为库”,然后选择一个模块,然后按确定。
You can see the .jar
file in build.gradle
file within the dependencies block. 您可以在依赖项块中的
build.gradle
文件中看到.jar
文件。
I do not know how to call the classes within the jar file which is added to gradle.build. 我不知道如何调用添加到gradle.build的jar文件中的类。 What i tried is:
我尝试的是:
My jar file is named zombi.jar and contains the class combi which i want to execute. 我的jar文件名为zombi.jar,包含我想要执行的类组合。
In MainActivity.java, I defined a variable like this: private COMBI mCOMBI; 在MainActivity.java中,我定义了一个这样的变量:private COMBI mCOMBI; (COMBI IS THE CLASS I NEED TO CALL WITHIN THE JAR FILE) In onCreate method, I added a call to combi like this: mCOMBI.COMBIStart();
(COMBI是我需要在JAR文件中调用的类)在onCreate方法中,我添加了一个对combi的调用:mCOMBI.COMBIStart(); (COMBIStart is the method within combi class that will execute the project).
(COMBIStart是将执行项目的combi类中的方法)。
I got errors all over the place. 我到处都有错误。 What to do?
该怎么办? Lina
丽娜
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.