将库添加到 android 工作室

Add library to android studio

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "jzdevelopers.ml.schoolbinder"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0.0"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
}

}

repositories {
maven { url "https://jitpack.io" }

maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

jcenter()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.commonsware.cwac:richedit:0.5.2'
compile 'org.sufficientlysecure:html-textview:1.4'
compile ('com.github.NightWhistler:HtmlSpanner:0.4')
compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') {
    transitive = true
}
compile('com.github.ganfra:material-spinner:1.1.1') {
    exclude group: 'com.nineoldandroids', module: 'library'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile('com.rengwuxian.materialedittext:library:2.1.4') {
    exclude group: 'com.nineoldandroids', module: 'library'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
  }

错误:任务“:app:transformResourcesWithMergeJavaResForDebug”执行失败。

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE.txt File1: /Users/JordanZimmitti/.gradle/caches/modules-2/files-2.1/org.jdom/jdom/1.1/1d04c0f321ea337f3661cf7ede8f4c6f653a8fdd/jdom-1.1.jar File2: /Users/JordanZimmitti/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.7.0/9746af1a485e50cf18dcb232489032a847067066/ant-1.7.0.jar

使用“JitPack”,一旦集成到 gradle 中,输入用户的 link 和他的 github 存储库的名称。 对于这种特定情况,您应该这样写:

compile 'com.github.NightWhistler:HtmlSpanner:0.4'

当然在存储库中添加这一行,因为您还会找到官方网站

maven { url "https://jitpack.io" }

编辑

编辑您的 build.gradle

    apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "jzdevelopers.ml.schoolbinder"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0.0"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
}

}

repositories {
maven { url "https://jitpack.io" }

maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

jcenter()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.commonsware.cwac:richedit:0.5.2'
compile 'org.sufficientlysecure:html-textview:1.4'
compile 'com.github.NightWhistler:HtmlSpanner:0.4'
compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') {
    transitive = true
}
compile('com.github.ganfra:material-spinner:1.1.1') {
    exclude group: 'com.nineoldandroids', module: 'library'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile('com.rengwuxian.materialedittext:library:2.1.4') {
    exclude group: 'com.nineoldandroids', module: 'library'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
  }