Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in constrained layouts #441

Closed
xinbai240524 opened this issue Dec 3, 2023 · 6 comments
Closed

Doesn't work in constrained layouts #441

xinbai240524 opened this issue Dec 3, 2023 · 6 comments

Comments

@xinbai240524
Copy link

I'm using the 8.1.1 version of gradle and then I added the sentence implementation("de.hdodenhof:circleimageview:3.1.0") to my build.gradle.kts, but after adding de.hdodenhof.circleimageview.CircleImageView to xml, it doesn't work.And it also reported Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.

build.gradle.kts:

import java.util.regex.Pattern.compile

plugins {
    id("com.android.application")
}

android {
    namespace = "com.wqx.music"
    compileSdk = 33

    defaultConfig {
        applicationId = "com.wqx.music"
        minSdk = 24
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = 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.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation("de.hdodenhof:circleimageview:3.1.0")

    implementation(files("libs\\activation.jar"))
    implementation(files("libs\\additionnal.jar"))
    implementation(files("libs\\mail.jar"))
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#FD4568"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/user_icon"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@drawable/icon_picture"
        app:civ_border_width="2dp"
        app:civ_border_color="#FF000000"
        tools:ignore="MissingClass,MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
@CarlosSac
Copy link

Hi, I could not reproduce the issue with the CircleImageView library on my end. Here is what I did:

  • I used Gradle 8.0 and Android Gradle Plugin 8.1.3 in my project settings.
  • I added the following line to the dependencies block of my app's build.gradle.kts file:
implementation("de.hdodenhof:circleimageview:3.1.0")
dependencies {

    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    
    implementation("de.hdodenhof:circleimageview:3.1.0")
    
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
  • I used the de.hdodenhof.circleimageview.CircleImageView class in my xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#FD4568"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/user_icon"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@drawable/ic_launcher_foreground"
        app:civ_border_color="#FF000000"
        app:civ_border_width="2dp"
        tools:ignore="MissingClass,MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
  • I ran the app and everything worked fine. I did not encounter any errors or warnings. Here is a screenshot of how the app looks like on my device:

Screenshot of the app

I’m sorry to hear that you are having this problem. I was not able to replicate it on my end, so I’m not sure what is causing it. I hope you can find a way to fix the issue.

@xinbai240524
Copy link
Author

de.hdodenhof.circleimageview.CircleImageView

Thank you, but I still can't solve it at the moment, I looked at it again, and it says failed to resolve de.hdodenhof.circleimageview.CircleImageView, but I really don't know what to do...

@MohammedAbidNafi
Copy link

Just make sure you have these in your settings.gradle file am not sure exactly which one would work so make sure you have all of the things below in your settings.gradle file

pluginManagement {
    repositories {
        google() //THESE
        mavenCentral() //THESE
        maven { url 'https://jitpack.io' } //THESE
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google() //THESE
        mavenCentral() //THESE
        maven { url 'https://jitpack.io' } //THESE
    }
}


@xinbai240524
Copy link
Author

Just make sure you have these in your settings.gradle file am not sure exactly which one would work so make sure you have all of the things below in your settings.gradle file

pluginManagement {
    repositories {
        google() //THESE
        mavenCentral() //THESE
        maven { url 'https://jitpack.io' } //THESE
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google() //THESE
        mavenCentral() //THESE
        maven { url 'https://jitpack.io' } //THESE
    }
}

Thank you for your answer, I followed your suggestion and added the above code to my setting file, now my setting file content is:

import javax.print.DocFlavor.URL

pluginManagement {
    repositories {
        google()
        mavenCentral()
        maven { url  = uri("https://jitpack.io") }
        //maven { url 'https://jitpack.io' } //THESE
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url  = uri("https://jitpack.io") }
    }
}

rootProject.name = "music"
include(":app")
 

my xml file content is:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#FD4568"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/profile_image"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@drawable/truck"
        app:civ_border_width="2dp"
        app:civ_border_color="#FF000000"
        tools:ignore="MissingClass,MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

my build.gradle.kts file content is:

import java.util.regex.Pattern.compile

plugins {
    id("com.android.application")
}

android {
    namespace = "com.wqx.music"
    compileSdk = 33

    defaultConfig {
        applicationId = "com.wqx.music"
        minSdk = 24
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = 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.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation("de.hdodenhof:circleimageview:3.1.0")

    implementation(files("libs\\activation.jar"))
    implementation(files("libs\\additionnal.jar"))
    implementation(files("libs\\mail.jar"))
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

This Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app: The debugRuntimeClasspath error persists, do you have any other suggestions?

@xinbai240524
Copy link
Author

Hi, I could not reproduce the issue with the CircleImageView library on my end. Here is what I did:

  • I used Gradle 8.0 and Android Gradle Plugin 8.1.3 in my project settings.
  • I added the following line to the dependencies block of my app's build.gradle.kts file:
implementation("de.hdodenhof:circleimageview:3.1.0")
dependencies {

    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    
    implementation("de.hdodenhof:circleimageview:3.1.0")
    
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
  • I used the de.hdodenhof.circleimageview.CircleImageView class in my xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#FD4568"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/user_icon"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@drawable/ic_launcher_foreground"
        app:civ_border_color="#FF000000"
        app:civ_border_width="2dp"
        tools:ignore="MissingClass,MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
  • I ran the app and everything worked fine. I did not encounter any errors or warnings. Here is a screenshot of how the app looks like on my device:

Screenshot of the app

I’m sorry to hear that you are having this problem. I was not able to replicate it on my end, so I’m not sure what is causing it. I hope you can find a way to fix the issue.

Can I ask you about the version of your Android SDK? I once asked my teacher and he suggested that I unify the version of the SDK with you

@xinbai240524
Copy link
Author

I solved it!!!!! It's because my gradle is there, I chose online, and I just canceled it!!! Thank you so much!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants