Motion Editor not working in Android Studio 4.0

Viewed 2890

I downloaded Android Studio 4.0 (canary channel) and I'm trying to create a motion layout but the editor is greyed out, an error that usually means there's something wrong with the dependencies. I have updated all the relevant ones I could think of (as seen below), and I've rebuilt the project (also done invalidating caches and restart), but the problem persists. What am I missing?

build.gradle (app):

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.android.aboutme"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding{
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.60-eap-25"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

build.gradle (project):

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0-alpha01'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.60-eap-25"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- activity_main.xml -->
<androidx.constraintlayout.motion.widget.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/motionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/so_scene"
    tools:showPaths="true">

    <View
        android:id="@+id/button"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:background="@color/colorAccent"
        android:text="Button" />

</androidx.constraintlayout.motion.widget.MotionLayout>
1 Answers

Try to delete app/build/ directory and rebuild project then.

I had a problem like you describe though the issue was not with dependencies, but with MotionLayout class initialization in Motion Editor. You may check messages by clicking icon at the top right of Motion Editor (icon might be "info" or "warning"), like here:

Warnings button in UI Editor

I can't reproduce the error I had, but it was about missing attribute motion_base in MotionScene initialization. Removing the app/build/ dir and getting it regenerated solved the issue.

Related