【问题标题】:Motion Editor not working in Android Studio 4.0运动编辑器在 Android Studio 4.0 中不起作用
【发布时间】:2019-10-24 15:04:06
【问题描述】:

我下载了 Android Studio 4.0(canary 通道),我正在尝试创建一个动作布局,但编辑器是灰色的,这个错误通常意味着依赖项有问题。我已经更新了我能想到的所有相关内容(如下所示),并且我已经重建了项目(还完成了使缓存无效并重新启动),但问题仍然存在。我错过了什么?

build.gradle(应用程序):

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(项目):

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>

【问题讨论】:

    标签: android android-studio android-studio-4.0


    【解决方案1】:

    尝试删除app/build/目录,然后重建项目。

    我遇到了像你描述的问题,虽然问题不在于依赖关系,但在于运动编辑器中的 MotionLayout 类初始化。您可以通过点击动态编辑器右上角的图标来查看消息(图标可能是“信息”或“警告”),如下所示:

    我无法重现我遇到的错误,但它与 MotionScene 初始化中缺少属性 motion_base 有关。删除 app/build/ 目录并重新生成它解决了这个问题。

    【讨论】:

    • 我创建了一个新项目,它工作正常,因此在删除了为有问题的项目生成的所有文件并从快速菜单中删除了快捷方式后,我能够毫无问题地运行它。我知道那个警告图标,但是对于这个特殊的问题,我不记得看到过那个。不过还是谢谢你的建议!
    • 尝试了所有这些但仍然卡住
    猜你喜欢
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    相关资源
    最近更新 更多