将项目更新为Android X

时间:2019-06-13 12:06:07

标签: android gradle android-xml androidx

将项目更新为Android X后出现此问题。我在gradle.properties中启用了Android X和Jetifier:

android.useAndroidX=true
android.enableJetifier=true

,然后我去做项目,重构并迁移到AndroidX。此后,当我构建项目时,它显示以下错误:

warn: removing resource com.beatstars.mobile:string/com_facebook_loginview_logged_in_using_facebook_f1gender without required default value.
/Users/joaoluis/AndroidProjects/BeatStars/app/src/main/res/layout/fragment_player_collapsed.xml:2: error: attribute layoutDescription (aka com.beatstars.mobile:layoutDescription) not found.
/Users/joaoluis/AndroidProjects/BeatStars/app/src/main/res/layout/fragment_player_expanded.xml:2: error: attribute layoutDescription (aka com.beatstars.mobile:layoutDescription) not found.
/Users/joaoluis/AndroidProjects/BeatStars/app/src/main/res/xml/motion_player_swipe.xml:6: error: attribute constraintSetEnd (aka com.beatstars.mobile:constraintSetEnd) not found.
/Users/joaoluis/AndroidProjects/BeatStars/app/src/main/res/xml/motion_player_swipe.xml:6: error: attribute constraintSetStart (aka com.beatstars.mobile:constraintSetStart) not found.
error: failed linking file resources.

即使以前也可以。有人遇到过这个问题吗?

这是我的gradle文件:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.firebase-perf'

// Android Extensions
androidExtensions {
    experimental = true
}

android {

    compileSdkVersion targetSDK
    buildToolsVersion buildToolsVersion

    defaultConfig {
        applicationId appID
        minSdkVersion minSDK
        targetSdkVersion targetSDK
        versionName nameVersion
        versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : codeVersion

        // Instrumented Tests
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testHandleProfiling true
        testFunctionalTest true
    }

    // Needed For Twitter SDK
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    // Unit Test Options
    testOptions {
        reportDir "$rootDir/test-reports"
        resultsDir "$rootDir/test-results"
        unitTests.returnDefaultValues = true
        unitTests.includeAndroidResources = true
    }

    // Keys Config
    signingConfigs {
        debug {
            storeFile file(debugKeystoreProperties['storeFile'])
            storePassword debugKeystoreProperties['storePassword']
            keyAlias debugKeystoreProperties['keyAlias']
            keyPassword debugKeystoreProperties['keyPassword']
        }
        release {
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
        }
    }

    buildTypes {
        // Debug
        debug {

            // OneSignal Manifest
            manifestPlaceholders = [
                    onesignal_app_id: oneSignalAppIDDev,
                    onesignal_google_project_number: 'REMOTE'
            ]

            // Other Settings
            ext.enableCrashlytics = false
            testCoverageEnabled true
            signingConfig signingConfigs.debug
            minifyEnabled false
        }

        // Dev Vars
        dev {
            // OneSignal Manifest
            manifestPlaceholders = [
                    onesignal_app_id: oneSignalAppIDDev,
                    onesignal_google_project_number: 'REMOTE'
            ]

            // Other Settings
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testCoverageEnabled true
            signingConfig signingConfigs.release
            minifyEnabled false
        }

        // Stage
        stage {

            // OneSignal Manifest
            manifestPlaceholders = [
                    onesignal_app_id: oneSignalAppIDDev,
                    onesignal_google_project_number: 'REMOTE'
            ]

            // Other Settings
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testCoverageEnabled true
            signingConfig signingConfigs.release
            minifyEnabled false
        }

        // Release
        release {

            // OneSignal Manifest
            manifestPlaceholders = [
                    onesignal_app_id: oneSignalAppIDProd,
                    onesignal_google_project_number: 'REMOTE'
            ]

            // Other Settings
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testCoverageEnabled false
            signingConfig signingConfigs.release
            minifyEnabled false
            debuggable false
        }
    }
}

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

        // Android Libs
        implementation 'androidx.browser:browser:1.0.0'
        implementation 'androidx.media:media:1.0.1'
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'androidx.recyclerview:recyclerview:1.0.0'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.palette:palette:1.0.0'

        // Compute Colors most used in image
        implementation 'com.google.android.material:material:1.0.0'

        // Constrains Layouts
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

        /** Tools **/
        // Working with Texts Spans
        implementation 'me.gujun.android:span:1.7'
        // Image Picker and Editor
        implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
        // Working with Smooth Transitions
        implementation 'com.andkulikov:transitionseverywhere:1.8.1'
        // Keyboard Listener
        implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
        // Crash Activity View
        implementation 'cat.ereza:customactivityoncrash:2.2.0'

        /** Widgets **/
        // Fullscreen Loading
        implementation 'com.airbnb.android:lottie:3.0.6'
        // Fragments Bottom Tabs Navigation
        implementation 'com.ncapdevi:frag-nav:2.4.0'
        // Youtube View Player
        implementation files('src/libs/YouTubeAndroidPlayerApi.jar')
        // Horizontal Carousel
        implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
        // Indicator for RecyclerViews
        implementation 'com.kingfisherphuoc:easy-recyclerview-indicator:1.2'
        // Image Badge
        implementation 'com.github.nikartm:image-support:1.0.4'
        // Button with Centered Images
        implementation 'com.github.Omega-R:OmegaCenterIconButton:0.0.3@aar'
        // CookieBar2, for Messages from Top and Bottom
        implementation 'com.github.jobernas:CookieBar2:1.1.4' //master-SNAPSHOT
        // Bubble Picker
        implementation 'com.github.jobernas:Bubble-Picker:v0.2.6' //develop-SNAPSHOT
        // Loader Fab Button
        implementation 'com.mikhaellopez:circularprogressbar:2.0.0'
        // Mentions Lib
        implementation 'com.github.percolate:mentions:0.1.1'
        // Sliding Panel for Player Container
        implementation 'com.sothree.slidinguppanel:library:3.4.0'
        // Photo Touch Working with version 1.2.7 (Not working in version 2.0.0)
        implementation 'com.chensl.rotatephotoview:rotatephotoview:1.0.5'

        // Several Adapters types for Recycler View
        implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
        implementation 'eu.davidea:flexible-adapter:5.0.6'

        //    implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
        //    implementation 'eu.davidea:flexible-adapter-livedata:1.0.0-b3'
        //    implementation 'eu.davidea:flexible-adapter-databinding:1.0.0'

        // Player
        implementation "com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion"
        implementation "com.google.android.exoplayer:exoplayer-hls:$exoPlayerVersion"
        implementation "com.google.android.exoplayer:extension-mediasession:$exoPlayerVersion"

        // RX Kotlin
        implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
        implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'

        // Glide
        implementation "com.github.bumptech.glide:glide:$glideVersion"
        kapt "com.github.bumptech.glide:compiler:$glideVersion"

        // Room Database
        implementation 'androidx.room:room-runtime:2.0.0'
        kapt 'androidx.room:room-compiler:2.0.0'

        // API and Communication
        implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
        implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
        implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
        implementation "nl.komponents.kovenant:kovenant:$kovenantVersion"
        implementation "nl.komponents.kovenant:kovenant-ui:$kovenantVersion"
        implementation "nl.komponents.kovenant:kovenant-rx:$kovenantVersion"

        // Download and File Manager
        implementation "com.liulishuo.okdownload:okdownload:$okDownloadVersion"
        implementation "com.liulishuo.okdownload:sqlite:$okDownloadVersion"
        implementation "com.liulishuo.okdownload:okhttp:$okDownloadVersion"

        // Report Feedback Tool
        implementation 'com.linkedin.shaky:shaky:1.1.1'

        // Google Sign-In
        implementation 'com.google.android.gms:play-services-auth:16.0.1'

        // Facebook SDK
        implementation "com.facebook.android:facebook-core:$facebookVersion"
        implementation "com.facebook.android:facebook-login:$facebookVersion"
        implementation "com.facebook.android:facebook-marketing:$facebookVersion"

        // Twitter SDK
        implementation('com.twitter.sdk.android:twitter:3.3.0@aar') {
            transitive = true
        }

        // Sound Cloud SDK
        implementation 'com.github.vpaliyX:SoundCloud-API:1.3.2'

        // Other SDKs
        // Ably SDK
        implementation "io.ably:ably-android:$ablyVersion"

        // One Signal SDK
        implementation "com.onesignal:OneSignal:$oneSignalVersion"

        // Firebase SDK
        implementation "com.google.firebase:firebase-core:$firebaseCoreVersion"
        implementation "com.google.firebase:firebase-perf:$firebasePerfVersion"

        // Fabric and Crashlytics
        implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
            transitive = true
        }

        // Lazy Loading helper for placeholders
        implementation 'com.facebook.shimmer:shimmer:0.4.0'

        // Debug Tools
        implementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
        implementation "com.squareup.leakcanary:leakcanary-support-fragment:$leakCanaryVersion"
        implementation "com.facebook.stetho:stetho:$stethoVersion"
        implementation "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
        implementation "com.facebook.stetho:stetho-js-rhino:$stethoVersion"

        // Tests
        testImplementation 'junit:junit:4.12'
        testImplementation 'androidx.test:core:1.2.0'
        testImplementation 'org.mockito:mockito-core:2.13.0'
        testImplementation 'org.hamcrest:hamcrest-library:1.3'

        // Android Instrumented Tests
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        androidTestImplementation 'androidx.annotation:annotation:1.1.0'

        // Optional -- Hamcrest library
        androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'

        // Optional -- UI testing with Espresso
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

        // Optional -- UI testing with UI Automator
        androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    }

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

Motion布局的声明如下:

<android.support.constraint.motion.MotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/containerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_mini_player"
    app:layoutDescription="@xml/motion_player_swipe"
    tools:showPaths="true"> 

运动场景:

<MotionScene
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Transition
        android:id="@+id/showUpTransition"
        app:constraintSetStart="@layout/fragment_player_collapsed"
        app:constraintSetEnd="@layout/fragment_player_expanded"
        app:duration="150" />
</MotionScene>

2 个答案:

答案 0 :(得分:0)

这不是因为您迁移了AndroidX,而是显示错误,其中某些字段必填默认值未提及,并且链接文件资源失败显示某些未链接资源,您可能会在日志文件中看到规范错误

答案 1 :(得分:0)

当我将库更新到最新版本androidx.constraintlayout:constraintlayout时,我设法解决了该问题:从1.1.32.0.0-beta1

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'