Error in adding external Jar libraries in android studio

Deadly 提交于 2020-01-07 05:39:26

问题


This is w.r.t Android Studio 1.3.2

So when i try to add the Repo from the Import Module->Import Existing Jar,the library is added as a separate module and included in the settings.gradle.

After this when I try to use the Jar, I get the message Add Library 'x' to the classpath Once i add this to the classpath,I am able to access the classes however the project does not build with the following error,

class Xx cannot be found(Xx belongs to the jar) Is there a work-around to this.

I can add the jar by creatings a libs folder in the app module and clicking on add as library. However I do not want the jar inside the main module.


回答1:


When you add any module dependency then it will not automatically added to gradle file.

You have to add that dependancy to gradle file manually..

Now here you are adding module to Android Studio project then, You have to add

  compile project(':module_name') 

So that you module will be attached to your app module.

Hope It will help.

Thank you.!




回答2:


Do something like this:

To import your module: Step-1; Goto File->new->import module. Select and import your module.

Step-2: In your app's build.gradle add compile project(':yourlibrary')

Step-3: Sync your gradle.

Now to add jar in the above module:

Step-1: Copy your jar file into your module's lib folder.

Step-2: In your module's build.gradle file add a dependency like compile files('libs/your_jar_file.jar')

Step-3 Sync your gradle and you are good to go.



来源:https://stackoverflow.com/questions/32367230/error-in-adding-external-jar-libraries-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!