Can't use some of L SDK features

2020-07-10 10:43发布

问题:

I'm trying to use the new Activity transitions in the new SDK.

I tried this line:

getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);

But the problem is that Window doesn't include FEATURE_CONTENT_TRANSITIONS.

I also tried this line:

getWindow().setExitTransition(new Explode());

And Explode class doesn't exist...

I already set my project to be compiled with L SDK (android-L) and use the new SDK tools (20.0.0)

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'
    defaultConfig {
        applicationId 'com.tester'
        minSdkVersion 'L'
        targetSdkVersion 'L'
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:support-v4:+"
}

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

回答1:

seems like you are not including the L SDK library in your build path. Are the libraries listed as dependency of your project?



回答2:

Try File -> Invalidate Caches / Restart.

If that doesn't work, you can try deleting ~/.AndroidStudioBeta (or ~/.AndroidStudioPreview, whichever you are using). It will clear all your settings so be prepared for that, but this solved the issue in my case.

For Mac, clear:
~/Library/Application Support/AndroidStudioBeta
~/Library/Caches/AndroidStudioBeta
~/Library/Logs/AndroidStudioBeta
~/Library/Preferences/AndroidStudioBeta