简体   繁体   English

将jar导入android应用

[英]Importing a jar into an android app

I am trying to import a jar file into an android app that I'm working on, but when I try to declare the import statement in my java code for the app, I get "cannot resolve symbol error". 我正在尝试将jar文件导入正在使用的android应用程序中,但是当我尝试在该应用程序的java代码中声明import语句时,出现“无法解析符号错误”。

The jar doesn't have a main method as it is just a class that hashes user passwords and stores the hash in a DB, among a few other things. jar没有main方法,因为它只是一个散列用户密码并将哈希存储在DB中的类,还有其他一些事情。 Here's a screen shot of the situation. 这是情况的屏幕截图。

I ran "sync project with gradle files" as well. 我也运行了“与gradle文件同步项目”。 I'm sure it is something simple. 我敢肯定这很简单。 Here's a link to some pics regarding my issue. 这是一些有关我的问题的图片的链接。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Error in importing, says package doesn't exist: 导入错误,表示软件包不存在:

You should add the jar to the compile list too: 您也应该将jar添加到编译列表中:

compile files('libs/Security.jar')

Hope it works. 希望它能工作。

在Android Studio中尝试“ File ->“使Invalidate Caches / Restart...然后选择“ Invalidate and Restart

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

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