【问题标题】:Implemented AppCompat library not found in my own android library dependency在我自己的 android 库依赖项中找不到已实现的 AppCompat 库
【发布时间】:2018-06-26 18:24:15
【问题描述】:

我已将 xten-framework Android 依赖库创建到 maven 存储库中,其中包含 appcompat、RecyclerView 和设计库的依赖实现。它运行良好,当我使用依赖项中的模块项目构建和运行它时没有任何问题。

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.xtensolutions.country:country-sdk:1.0.1'
    implementation project(':xten-framework')
}    

部署到 maven 存储库后,我从依赖项中删除了 implementation project(':xten-framework') 并添加了 implementation 'com.xtensolution.support:xten-framework:1.0. build.gradle

中的 0'
repositories {
    maven {
        url 'https://dl.bintray.com/myusername/maven/'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.xtensolutions.country:country-sdk:1.0.1'
    implementation 'com.xtensolution.support:xten-framework:1.0.0'
}

当我编译我的项目时,我得到包 android.support.v7.app.AppCompatActivity 不存在的错误

我不明白,当我的库中找到其他创建的类时,为什么在我自己的库中找不到支持 appcomapat 包。我会在哪里错误地开发一个支持 appcompat 的库项目?我想补充什么?

如果有人能给我正确的解决方案来解决这个问题,我非常感谢

【问题讨论】:

  • 您是否尝试添加“implementation 'com.android.support:appcompat-v7:27.1.1'”库?
  • 是的,我已经在我的库项目中添加了“com.android.support:appcompat-v7:27.1.1”作为依赖项,但仍然出现错误

标签: android android-appcompat android-library


【解决方案1】:

在您的库中,如果您使用以下依赖项:

dependencies {
     implementation 'com.android.support:appcompat-v7:25.2.0'
}

当您将库用于另一个项目时,该项目将看不到 support:appcompat 因为它没有暴露给您的项目。因此,您需要将support:appcompat 添加到您的应用程序模块中。

或者在你的库中使用api 而不是implementation,如下所示:

dependencies {
     api 'com.android.support:appcompat-v7:25.2.0'
}

【讨论】:

  • 我也尝试使用 'api' 而不是 'implementation' 但仍然是同样的问题。
  • 这很奇怪。 apicompile 一样工作,当你使用 compile 时会发生什么?
猜你喜欢
  • 1970-01-01
  • 2019-03-25
  • 1970-01-01
  • 1970-01-01
  • 2019-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
相关资源
最近更新 更多