2014-09-29 44 views
0

我从github下载了一个项目,该项目没有为项目试图找到的库RoundedImageView提供必要的库。我对Android有点新,并没有任何使用build.gradle文件的经验,根据库的自述文件,需要进行编辑。从Maven Central导入RoundedImageView

有人可以给我一步一步的如何导入这个库吗?这是我做了什么,截至目前: 1.从网上下载here

的javadoc.jar文件
  • 改变了我的gradle这个文件,看起来这样:

    buildscript{ 
        repositories{ 
         jcenter() //not sure what this is, it was already here 
         mavenCentral() //added this 
        } 
        dependencies{ 
         classpath 'com.android.tools.build:gradle:0.12.+' //already here 
         compile 'com.makeramen:roundedimageview:1.3.0' //added this 
        } 
    } 
    allprojects{ 
        repositories{ 
         jcenter() //already here 
         mavenCentral() // added this 
        } 
    } 
    
  • 我也做了一个libs文件夹,把jar文件放在那里,并将其添加到构建路径中......尽管没有摆脱我的错误。

    回答

    1
    1. 您不需要添加mavenCentral()。 JCenter是Maven Central的超集。
    2. 将依赖关系添加到buildScript使它们可用于构建脚本(因此是名称),而不是您尝试构建的项目。
    3. 将依赖关系添加到allprojects闭包(或者您需要的项目)。
    4. 当然,你不需要手动下载任何东西。这就是依赖管理器的用处。

    buildscript{ repositories{ jcenter() //not sure what this is, it was already here } dependencies{ classpath 'com.android.tools.build:gradle:0.12.+' //already here } } allprojects{ repositories{ jcenter() //already here } dependencies{ compile 'com.makeramen:roundedimageview:1.3.0' //added this } }