【问题标题】:Add github library as dependency not working添加 github 库作为依赖项不起作用
【发布时间】:2018-05-29 13:43:28
【问题描述】:

我正在尝试使用这个自定义 ListView

https://android-arsenal.com/details/1/2078#!description

这里的步骤是:

第 2 步。将特定的存储库添加到您的构建文件中:

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

第 3 步。 在构建文件中添加依赖项(不要忘记指定正确的限定符,通常是“aar”):

dependencies {
    compile 'com.github.THEONE10211024:WaterDropListView:7b51373b3b'
}

和说明中的说明

"2.在您的 Activity 或 Fragment 中实现 WaterDropListView.IWaterDropListViewListener。"

Public class MainActivity extends Activity implements WaterDropListView.IWaterDropListViewListener

所以我做到了:

在项目的bulid.gradle中:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://jitpack.io"
        }
    }
}

在模块 bulid.gradle

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.github.THEONE10211024:WaterDropListView:7b51373b3b'
}

gradle 同步时没有错误。 但是在MainActivity implements WaterDropListView.IWaterDropListViewListener中实现时

我得到“无法解析符号 WaterDropListView”

【问题讨论】:

    标签: android gradle dependencies


    【解决方案1】:

    这看起来不是一个有效的库。

    app/build.gradle 中引用

    apply plugin: 'com.android.application'
    

    图书馆应该是

    apply plugin: 'com.android.library'
    

    如果您真的想使用它,我建议您获取代码并在您的项目中创建自己的库模块。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 2018-06-30
    • 2014-03-14
    • 2017-03-27
    • 2021-09-23
    • 1970-01-01
    相关资源
    最近更新 更多