【问题标题】:MaterialContainerTransform unresolved refrenceMaterialContainerTransform 未解析的引用
【发布时间】:2020-09-23 13:34:02
【问题描述】:

我开始使用 Material Design 过渡。

根据documentation,我应该将以下内容添加到我的应用程序 gradle.build 文件中。我做到了。

dependencies {
//...
   api 'com.google.android.material:material:1.1.0'
}

(我也尝试过implementation 'com.google.android.material:material:1.1.0',因为github documentation 也显示使用implementation 代替api那么哪一个是正确的?

但是当我开始使用MaterialContainerTransform 时,我得到了错误“Unresolved reference: MaterialContainerTransform”

我特意导入的

import com.google.android.material.transition.platform.MaterialContainerTransform

但我仍然得到错误。

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
        setPreferencesFromResource(R.xml.notifications_preferences, rootKey)


        sharedElementEnterTransition = MaterialContainerTransform(requireContext())
}

如何让我的项目使用 MDC?

这是我的完整 Gradle 文件。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {

    compileSdkVersion 29
    def versionMajor = 2020
    def versionMinor = 10
    def versionPatch = 3
    def versionPatchMinor = 0

    defaultConfig {
        applicationId "com.mycompany.myapp"
        vectorDrawables.useSupportLibrary = true

        minSdkVersion 25
        targetSdkVersion 29

        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch * 10 + versionPatchMinor
        versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionPatchMinor}"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        }

        compileOptions.with {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }




    buildTypes {

        debug {
            minifyEnabled false
            debuggable true
        }


        release {

            debuggable true
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        dataBinding = true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    configurations {
        cleanedAnnotations
        compile.exclude group: 'org.jetbrains', module: 'annotations'
    }
}

dependencies {

    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation fileTree(dir: 'libs', include: ['*.jar']) 

    api 'com.google.android.material:material:1.1.0'


    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
    implementation 'androidx.core:core:1.3.0'
    implementation "androidx.core:core-ktx:1.3.0"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.preference:preference:1.1.1'

    implementation 'com.google.code.gson:gson:2.8.6'

    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.squareup.picasso:picasso:2.71828'

    // FIREBASE MESSAGING
    implementation 'com.google.firebase:firebase-messaging:20.2.0'
    implementation 'com.google.firebase:firebase-core:17.4.2'

    // GOOGLE PLAY SERVICES
    implementation 'com.google.android.gms:play-services-location:17.0.0'

    // BARCODE SCANNNIG
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
    implementation 'com.google.zxing:core:3.4.0'

    // SQUARE PAYMENTS
    implementation 'com.squareup.sdk:point-of-sale-sdk:2.0'

    // HERE MAPS
    implementation(name: 'HERE-sdk', ext: 'aar')
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.0.rc1'

    // TESTING
    testImplementation 'junit:junit:4.13'
}

repositories {
    google()
    jcenter()

    // HEREMAPS
    flatDir {
        dirs 'libs'
    }
}

apply plugin: 'com.google.gms.google-services'

【问题讨论】:

    标签: android kotlin gradle material-design material-components


    【解决方案1】:

    MaterialContainerTransform 是在 1.2.0-alpha05 版本中引入的

    【讨论】:

    • 谢谢。当谈到 Android 开发时,这是我的一个巨大的烦恼。没有什么是一致的。文档无处不在。搜索结果显示过时的内容。整个 Android 生态系统是一个巨大的分形模式。
    猜你喜欢
    • 2021-06-17
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 2018-05-31
    • 2023-01-16
    • 2019-08-19
    • 1970-01-01
    相关资源
    最近更新 更多