How to add local .jar file dependency to build.gradle file?

前端 未结 17 1928
攒了一身酷
攒了一身酷 2020-11-21 23:23

So I have tried to add my local .jar file dependency to my build.gradle file:

apply plugin: \'java\'

sourceSets {
    main {
        java {
            srcD         


        
17条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 23:36

    If you really need to take that .jar from a local directory,

    Add next to your module gradle (Not the app gradle file):

    repositories {
       flatDir {
           dirs 'libs'
       }
    }
    
    
    dependencies {
       implementation name: 'gson-2.2.4'
    }
    

    However, being a standard .jar in an actual maven repository, why don't you try this?

    repositories {
       mavenCentral()
    }
    dependencies {
       implementation 'com.google.code.gson:gson:2.2.4'
    }
    

提交回复
热议问题