我需要加密我的SharedPreferences,于是我决定尝试使用:
implementation 'androidx.security:security-crypto:1.0.0-rc01'
它需要最低的SDK版本为23,因此我将我的应用程序更改为与之兼容。
现在我看到了一堆红线,如下所示:
Duplicate class com.google.protobuf.Timestamp$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Timestamp$Builder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.TimestampOrBuilder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.TimestampProto found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Type found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Type$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Type$Builder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.TypeOrBuilder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.TypeProto found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt32Value found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt32Value$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt32Value$Builder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt32ValueOrBuilder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt64Value found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt64Value$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt64Value$Builder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UInt64ValueOrBuilder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.UninitializedMessageException found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnknownFieldSetLite found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnmodifiableLazyStringList found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnmodifiableLazyStringList$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnmodifiableLazyStringList$2 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnsafeUtil found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.UnsafeUtil$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Utf8 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Utf8$Processor found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Utf8$SafeProcessor found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Utf8$UnpairedSurrogateException found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Utf8$UnsafeProcessor found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Value found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Value$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Value$Builder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.Value$KindCase found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.ValueOrBuilder found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Duplicate class com.google.protobuf.WireFormat found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$FieldType found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$FieldType$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$FieldType$2 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$FieldType$3 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$FieldType$4 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$JavaType found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$Utf8Validation found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$Utf8Validation$1 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$Utf8Validation$2 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WireFormat$Utf8Validation$3 found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.WrappersProto found in modules jetified-protobuf-javalite-3.11.1.jar (com.google.protobuf:protobuf-javalite:3.11.1) and jetified-protolite-well-known-types-17.0.0-runtime.jar (com.google.firebase:protolite-well-known-types:17.0.0)
Go to the documentation to learn how to Fix dependency resolution errors.
我的 build.gradle 如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-analytics:17.4.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-firestore:21.4.3'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.ms-square:expandableTextView:0.1.4'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.google.firebase:firebase-functions:19.0.2'
implementation 'com.google.firebase:firebase-messaging:20.1.6'
implementation 'com.google.firebase:firebase-core:17.4.0'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'androidx.security:security-crypto:1.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}
我该如何解决这个问题?
谢谢
build.gradle
,就不会有更好的答案,因为这是不可重复的。取消接受正确答案并不会改善不准确的问题。 - Martin Zeitler