6

I'm Trying to add this https://github.com/ArthurHub/Android-Image-Cropper But when i add it i get this error "Error: Program type already present: androidx.versionedparcelable.ParcelImpl"

I have attached project gradle and app gradle. (i'm new to android development and am not entirely sure how to fix.)

i think it might have something to do with

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

But these are used for TextInputLayout in one of my layouts for an activity. Any help will be greatly appreciated.

  // 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'
Yee-haw
  • 75
  • 1
  • 1
  • 4
  • Try to replace `api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'` to `implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'` – punchman Nov 01 '18 at 04:30

5 Answers5

7

You use support library whereas new version of Image-Cropper Library used androidx library.

check change log

So, You have two option either you can move to androidx or change library version to old version

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

Abhay Koradiya
  • 2,068
  • 2
  • 15
  • 40
  • Thank you for this. This solved my problem. I had an issue with the app compat library that needed an older library instead. – SaundersB Aug 30 '19 at 15:45
4

I solved my issue by downgrading butterknife dependencies to version 8.8.1

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

Alternatively, another solution was me for searching through entire project files for any import statements using androidx and then replacing them with the android.support version.

In my case I found -

import androidx.annotation.NonNull; which I replaced with import android.support.annotation.NonNull;

Aishwary Dhare
  • 509
  • 1
  • 6
  • 18
1

You can keep latest version and configure gradle to use AndroidX

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

gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

From Doc Using AndroidX

See Migrating to AndroidX to learn how to migrate an existing project.

If you want to use AndroidX in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher and set both of the following Android Gradle plugin flags to true in your gradle.properties file.

android.useAndroidX: When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.

android.enableJetifier: When set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. The flag is false by default if it is not specified.

Khaled Lela
  • 7,831
  • 6
  • 45
  • 73
0

You need to use api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

Because android-image-cropper:2.8.+' is Update to support library to AndroidX

For com.android.support Use this

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

For AndroidX Use this

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

Change log 2.8.0

  • Fix crash on Android O

  • Update to support library to AndroidX

  • Handle failure when selecting non image file

  • More translations

For more information Please Read the Change log of Android Image Cropper

Community
  • 1
  • 1
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

If you have added a model cropper , remove it and add

For com.android.support Use this

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

For AndroidX Use this

api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
Moaz Ragab
  • 186
  • 5