【问题标题】:Integrate additional Libraries - Android Studio集成其他库 - Android Studio
【发布时间】:2021-10-23 23:11:18
【问题描述】:

我正在添加一个外部库:-

implementation 'com.hbb20:ccp:X.Y.Z'

我正在将此依赖项添加到 app 模块中的 build.gradle 文件中。成功同步项目后,当我在我的 xml 文件中添加该特定依赖项时,它不起作用。我使用了以下代码:-

<com.hbb20.CountryCodePicker
    android:id="@+id/ccp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

这显示以下错误:-

Class referenced in the layout file, com.hbb20.CountryCodePicker, was not found in the project or the libraries
Cannot resolve class com.hbb20.CountryCodePicker 

在 JAVA 文件中调用私有国家代码时也显示错误。我该怎么办?

【问题讨论】:

    标签: android android-studio gradle dependencies


    【解决方案1】:

    X.Y.Z 应该是特定的依赖版本,
    我能看到的最新版本是 2.5.4,正如库的存储库中提到的那样。

    你应该像这样添加依赖:

    implementation 'com.hbb20:ccp:2.5.4'
    

    【讨论】:

    • 非常感谢!这对我很有帮助。
    • 如果有帮助,请接受作为答案。 :)
    【解决方案2】:

    而不是 X.Y.Z。你应该这样写一个版本号

    implementation 'com.hbb20:ccp:2.5.4'
    

    【讨论】:

    • 非常感谢!这对我很有帮助。
    • 如果这个答案对你有用。请采纳答案
    猜你喜欢
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 2018-06-17
    相关资源
    最近更新 更多