Java 无法实现图像裁剪

Java 无法实现图像裁剪,java,android-studio,android-manifest,Java,Android Studio,Android Manifest,当我同步API“com.theartofdev.edmodo:android image-crapper:2.8.+”时,它在实现“com.android.support:appcompat-v7:28.0.0”下面加下划线: enter dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:2

当我同步API“com.theartofdev.edmodo:android image-crapper:2.8.+”时,它在实现“com.android.support:appcompat-v7:28.0.0”下面加下划线:

enter dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'


}




你的用例是什么?你们有哪种格式的图像?(位图、Uri或它在blop存储中) 为什么不调整图像的大小而不是裁剪

如果图像在位图中,如果有帮助,下面是调整图像大小的代码

 /**
 * reduces the size of the image
 * @param image
 * @param maxSize
 * @return
 */
fun getResizedBitmap(image: Bitmap, maxSize: Int): Bitmap {
    var width: Int = image.width
    var height: Int = image.height

    val bitmapRatio: Double = (width / height).toDouble()
    if (bitmapRatio > 1) {
        width = maxSize
        height = (width / bitmapRatio).toInt()
    } else {
        height = maxSize
        width = (height * bitmapRatio).toInt()
    }
    return Bitmap.createScaledBitmap(image, width, height, true)
}

你的用例是什么?你们有哪种格式的图像?(位图、Uri或它在blop存储中) 为什么不调整图像的大小而不是裁剪

如果图像在位图中,如果有帮助,下面是调整图像大小的代码

 /**
 * reduces the size of the image
 * @param image
 * @param maxSize
 * @return
 */
fun getResizedBitmap(image: Bitmap, maxSize: Int): Bitmap {
    var width: Int = image.width
    var height: Int = image.height

    val bitmapRatio: Double = (width / height).toDouble()
    if (bitmapRatio > 1) {
        width = maxSize
        height = (width / bitmapRatio).toInt()
    } else {
        height = maxSize
        width = (height * bitmapRatio).toInt()
    }
    return Bitmap.createScaledBitmap(image, width, height, true)
}

您正在使用gradle dependency,它包含的版本比支持compat的版本大。意思可能是最后包含的依赖项,包含的版本比您拥有的版本大。另外,请避免在依赖项版本末尾使用+。了解它并用实际版本替换它,例如:“2.8.0”。它应该被替换,因为它可能在某个时候破坏您的构建。查看此处了解更多信息:

api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
替换为:

api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

也尝试用更新的版本替换您的支持版本,或者考虑使用Android X依赖项:

implementation androidx.appcompat:appcompat:1.0.0

尝试与技术保持同步,使用最新版本!:)

您使用的是gradle dependency,它包含的版本比支持compat的版本大28.0.0。意思可能是最后包含的依赖项,包含的版本比您拥有的版本大。另外,请避免在依赖项版本末尾使用+。了解它并用实际版本替换它,例如:“2.8.0”。它应该被替换,因为它可能在某个时候破坏您的构建。查看此处了解更多信息:

api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
替换为:

api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

也尝试用更新的版本替换您的支持版本,或者考虑使用Android X依赖项:

implementation androidx.appcompat:appcompat:1.0.0

尝试与技术保持同步,使用最新版本!:)

首先,请阅读问题。OP并不是要求实施。Gradle无法同步项目。首先,请阅读问题。OP并不是要求实施。Gradle无法同步项目。可能他们正在实现此
com.android的不同版本。支持:appcompat-v7:28.0.0
依赖项。将鼠标悬停在红线上方,应该会显示问题所在。可能他们正在实现此
com.android的不同版本。支持:appcompat-v7:28.0.0
依赖项。将鼠标悬停在红线上,它会显示问题所在。