【问题标题】:Issue with importing libraries in Android Studio在 Android Studio 中导入库的问题
【发布时间】:2018-12-26 05:36:32
【问题描述】:

我有一个带有gradle 2.2.0android-apt plugin 1.8 的Android 项目。我有时间将其更新为更新的工具 gradle 3.1.0 并删除 apt 插件以使用带有 implementation/CompileOnly 和注释处理器关键字的更新建议的解决方案。在该项目正确构建/编译并将 apk 文件推送到设备之后,但是当我打开使用的类时:butterknife, tourguide, FancyToast or material-dialogs 库类看不到此依赖项(导入和引用标记为红色)。

有人遇到过同样的问题吗? 当前依赖项:

依赖{ 实施 'com.android.support:support-v4:27.1.1' 实施 'com.android.support:appcompat-v7:27.1.1' 实施 'com.android.support:recyclerview-v7:27.1.1' 实施 'com.android.support:cardview-v7:27.1.1' 实现 'com.android.support:design:27.1.1'

implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

annotationProcessor "org.projectlombok:lombok:1.16.12"
compileOnly "org.projectlombok:lombok:1.16.12"

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

implementation ('com.github.worker8:tourguide:1.0.14-SNAPSHOT@aar') {
    transitive = true;
}
implementation files('libs/greendao-2.1.0.jar')

implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
//dagger
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'com.google.dagger:dagger:2.0.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'



implementation('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
    transitive = true;
}
//save player objects (protect from removing it)
implementation 'com.google.code.gson:gson:2.7'

//permutation library
implementation 'com.googlecode.combinatoricslib:combinatoricslib:2.1'

//new toasts
implementation 'com.github.Shashank02051997:FancyToast-Android:0.1.3'

//tests
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:2.+"}

项目可以编译/工作,但使用这个库是个障碍

【问题讨论】:

    标签: android android-studio


    【解决方案1】:

    如果你的依赖声明在不同的模块中,你应该使用 api 而不是实现 例如:

    api 'com.google.dagger:dagger:2.0.2'
    

    【讨论】:

    • 我只使用一个模块“app”
    猜你喜欢
    • 1970-01-01
    • 2015-10-29
    • 2016-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 2020-11-04
    • 1970-01-01
    相关资源
    最近更新 更多