Error: Program type already present: androidx.versionedparcelable.ParcelImpl
Error: Program type already present: androidx.versionedparcelable.ParcelImpl
我正在尝试添加这个 https://github.com/ArthurHub/Android-Image-Cropper 但是当我添加它时我得到这个错误 "Error: Program type already present: androidx.versionedparcelable.ParcelImpl"
我已附加项目 gradle 和应用程序 gradle。 (我是 android 开发的新手,不完全确定如何修复。)
我认为这可能与
有关
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"
但是在我的 activity 布局之一中,这些用于 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
}
应用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'
您需要使用
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
因为 android-image-cropper:2.8.+'
更新支持库到 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.+'
更新日志 2.8.0
修复 Android O
上的崩溃
更新支持库到 AndroidX
选择非图像文件时处理失败
更多翻译
有关详细信息,请阅读 Android Image Cropper
的 Change log
您使用了支持库,而 Image-Cropper
库的新版本使用了 androidx
库。
所以,您有两个选择,您可以移动到 androidx
或将库版本更改为旧版本
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
您可以保留最新版本并配置 gradle
以使用 AndroidX
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
来自医生 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.
我通过将 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;
替换了
如果您添加了模型裁剪器,请将其删除
并添加
对于com.android.support使用这个
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
对于 AndroidX 使用这个
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
我正在尝试添加这个 https://github.com/ArthurHub/Android-Image-Cropper 但是当我添加它时我得到这个错误 "Error: Program type already present: androidx.versionedparcelable.ParcelImpl"
我已附加项目 gradle 和应用程序 gradle。 (我是 android 开发的新手,不完全确定如何修复。)
我认为这可能与
有关implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"
但是在我的 activity 布局之一中,这些用于 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
}
应用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'
您需要使用
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
因为 android-image-cropper:2.8.+'
更新支持库到 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.+'
更新日志 2.8.0
修复 Android O
上的崩溃更新支持库到 AndroidX
选择非图像文件时处理失败
更多翻译
有关详细信息,请阅读 Android Image Cropper
的Change log
您使用了支持库,而 Image-Cropper
库的新版本使用了 androidx
库。
所以,您有两个选择,您可以移动到 androidx
或将库版本更改为旧版本
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
您可以保留最新版本并配置 gradle
以使用 AndroidX
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
来自医生 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.
我通过将 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;
如果您添加了模型裁剪器,请将其删除 并添加
对于com.android.support使用这个
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
对于 AndroidX 使用这个
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'