【问题标题】:Add library to android studio将库添加到 android studio
【发布时间】:2016-03-06 16:05:35
【问题描述】:
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:在 APK META-INF/LICENSE.txt 中复制的文件重复 文件1:/Users/JordanZimmitti/.gradle/caches/modules-2/files-2.1/org.jdom/jdom/1.1/1d04c0f321ea337f3661cf7ede8f4c6f653a8fdd/jdom-1.1.jar 文件2:/Users/JordanZimmitti/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.7.0/9746af1a485e50cf18dcb232489032a847067066/ant-1.7.0.jar

【问题讨论】:

标签: android shared-libraries


【解决方案1】:

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

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

当然是在repositories里面添加这一行,官方网站也可以找到

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'
}
  }

【讨论】:

  • 您在maven中输入了存储库的顺序?然后你进入了依赖检查编译?如果你给我带来错误jitpack.io
  • 测试新的编译代码:为我不确定的版本编译'com.github.nightwhistler:HtmlSpanner:2.16',但当前描述的页面和github(版本2.16)。
  • 这里我更新了版本,现在你该走了。编译'com.github.NightWhistler:HtmlSpanner:0.4'
  • 你最好的!你从哪里得到的 0.4 我一直在寻找它
  • 您在下拉菜单“分支”中找到的版本,选择它们“标签”并查看版本
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-17
  • 2019-02-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-07
  • 2014-02-04
  • 1970-01-01
相关资源
最近更新 更多