0

The implementation is in the build.gradle file, but I'm still getting "Cannot resolve class com.hbb20.CountryCodePicker" in the main activity

This is the build.gradle file:

plugins {
    id 'com.android.application'
}

android {
    namespace 'com.example.assignment1'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.assignment1"
        minSdk 21
        targetSdk 33
        versionCode 1
        versionName "1.0"


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.hbb20:ccp:2.6.1'
}

This is the activity_main.xml:

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    tools:context=".MainActivity">



<ImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:src="@drawable/ic_launcher_background"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="40dp"
    android:id="@+id/logo"/>

<com.hbb20.CountryCodePicker
    android:layout_width="match_parent"
    android:layout_height="50dp"
    app:ccp_areaCodeDetectedCountry="true"
    android:layout_centerInParen="true"
    android:layout_marginleft="100dp"
    android:layout_marginright="100dp"
    android:id="@+id/contrycodePicker"
    app:ccp_autoDetectCountry="true"
    android:layout_above="@id/centerhorizontalline"/>

The <com.hbb20.countrycodepicker> shows up as an error. What is the problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

1 Answers1

1

You must take the following steps when you encounter a problem when adding a new dependency.

First

You must ensure that the correct repositories are used in the repositories list in build.gradle(project)

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

Second

Go to men FileSync project

Enter image description here

These steps work fine for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Amr Shekh Zen
  • 41
  • 1
  • 8