проблема зависимости androidx.security - PullRequest
0 голосов
/ 29 апреля 2020

Мне нужно было зашифровать мои 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()
}

Как я могу это исправить проблема?

Спасибо

Ответы [ 3 ]

4 голосов
/ 29 апреля 2020

Это зависит от com.google.crypto.tink:tink-android:1.3.0, который вытягивает protobuf-javalite:

implementation ("androidx.security:security-crypto:1.0.0-rc01") {
    exclude group: "com.google.protobuf", module: "protobuf-javalite"
}
1 голос
/ 03 мая 2020

В трекере ошибок объявлена ​​проблема: https://issuetracker.google.com/issues/154434594

Этот обходной путь работает для меня:

allprojects {
    configurations.all {
        resolutionStrategy {
            force("com.google.crypto.tink:tink-android:1.3.0-rc1")
        }
    }
}
1 голос
/ 29 апреля 2020

Дубликат класса com.google.protobuf

Вы можете добавить ниже в разделе МОДУЛЬ уровень build.gradle.

android {

  configurations {
        implementation.exclude module:'proto-google-common-protos'
        implementation.exclude module:'protobuf-java'
        }

}
...