集成其他库 - Android Studio

Integrate additional Libraries - Android Studio

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

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

我正在将此依赖项添加到应用程序模块中的 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 文件中的私人国家代码时,它显示错误。我该怎么办?

而不是 X.Y.Z。你应该输入这样的版本号

implementation 'com.hbb20:ccp:2.5.4'

X.Y.Z应该是特定的依赖版本,
我能看到的最新版本是 2.5.4,如图书馆存储库中所述。

您应该像这样添加依赖项:

implementation 'com.hbb20:ccp:2.5.4'