错误:程序类型已存在:androidx.versionedparcelable.ParcelImpl

问题描述 投票:2回答:4

我正在尝试添加这个https://github.com/ArthurHub/Android-Image-Cropper但是当我添加它时我得到这个错误“错误:程序类型已经存在:androidx.versionedparcelable.ParcelImpl”

我附加了项目gradle和app gradle。 (我是Android开发的新手,并不完全确定如何修复。)

我认为这可能与某些事情有关

implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"

但是这些用于我的一个活动布局中的TextInputLayout。任何帮助将不胜感激。

  // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {

        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath 'com.google.gms:google-services:4.0.0'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            google()
            jcenter()
            maven{
               url  "https://maven.google.com"
            }
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

App Gradle:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.something.app"
            minSdkVersion 24
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

        ext {
            supportLibVersion = '27.1.1'  // variable that can be referenced to keep support libs consistent
            }

    dependencies {

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

        implementation "com.android.support:appcompat-v7:${supportLibVersion}"
        implementation "com.android.support:design:${supportLibVersion}"
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
        implementation 'com.android.support:design:28.0.0-rc01'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.google.firebase:firebase-core:16.0.4'
        implementation 'com.google.firebase:firebase-auth:16.0.4'
        implementation 'com.google.firebase:firebase-database:16.0.3'
        implementation 'com.google.firebase:firebase-storage:16.0.3'
        testImplementation 'junit:junit:4.12'
        implementation 'de.hdodenhof:circleimageview:2.2.0'
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation 'com.android.support:support-v4:28.0.0'
        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-rc01'



        //implementation 'com.google.android.gms:play-services-maps:16.0.0'
        // implementation 'com.google.android.gms:play-services-analytics:7.3.0'
        implementation 'com.google.android.gms:play-services-maps:16.0.0'
        implementation 'com.google.android.gms:play-services-location:16.0.0'
        implementation 'com.google.android.gms:play-services-analytics:16.0.4'
        implementation 'com.google.android.gms:play-services-places:16.0.0'
    }

    apply plugin: 'com.google.gms.google-services'
android gradle compiler-errors androidx
4个回答
3
投票

您使用支持库,而新版本的Image-Cropper库使用androidx库。

检查change log

所以,你有两个选择,你可以移动到androidx或将库版本更改为旧版本

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


4
投票

我通过将butterknife依赖关系降级到版本8.8.1解决了我的问题

// BUTTERKNIFE
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

或者,另一个解决方案是我使用androidx在整个项目文件中搜索任何导入语句,然后用android.support版本替换它们。

就我而言,我发现 -

我用import androidx.annotation.NonNull;取代的import android.support.annotation.NonNull;


1
投票

您可以保留最新版本并配置gradle以使用AndroidX

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

grad了.properties:

android.useAndroidX=true
android.enableJetifier=true

来自Doc Using AndroidX

请参阅迁移到AndroidX以了解如何迁移现有项目。

如果要在新项目中使用AndroidX,则需要将compile SDK设置为Android 9.0(API级别28)或更高版本,并在gradle.properties文件中将以下两个Android Gradle插件标志设置为true。

android.useAndroidX:设置为true时,Android插件使用相应的AndroidX库而不是支持库。如果未指定,则默认情况下该标志为false。

android.enableJetifier:当设置为true时,Android插件会自动迁移现有的第三方库,通过重写其二进制文件来使用AndroidX。如果未指定,则默认情况下该标志为false。


0
投票

你需要使用api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

因为android-image-cropper:2.8.+'是更新以支持AndroidX的库

对于com.android.support使用此选项

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

对于AndroidX使用此

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

更改日志2.8.0

  • 修复Android O上的崩溃问题
  • 更新以支持AndroidX的库
  • 选择非图像文件时处理失败
  • 更多翻译

有关更多信息,请阅读Android Image Cropper的Change log

© www.soinside.com 2019 - 2024. All rights reserved.