简体   繁体   中英

Android Studio not recognizing ShortcutManager class

I'm looking into shortcut creation with Android O. Unfortunately Android Studio is not recognizing the ShortcutManager class:

在此输入图像描述

In the gradle file I have set as a dependency:

compile 'com.android.support:appcompat-v7:25.3.1'

In the gradle file I have these versions set:

compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
    minSdkVersion 25
    targetSdkVersion 25

I have followed the steps in this SO response and executed File => Invalidate Caches / Restart...

Unfortunately Android Studio continues to not recognize the class.

Information on my version of Android Studio:

Android Studio 2.3.2
Build #AI-162.3934792, built on April 21, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Attempting to manually import the class is not successful:

在此输入图像描述

In addition to assuring that Android Studio version number is at 2.3, the breakthrough I had was finding this documentation for migrating to Android O . In the section "Get the Android O SDK" it prescribes both platform and tool updates that are initiated by launching from the Android Studio menu Tools > Android > SDK Manager .

Here's a screenshot for which platform components I needed to update:

在此输入图像描述

When combined with the required tools updates, these were combined updates required:

在此输入图像描述

Then, you must take care to follow the required updates to your build configuration outlined in the section "Update your build configuration", an element that I had missed was the maven update:

android {
  compileSdkVersion 26
  buildToolsVersion '26.0.0-rc3'

  defaultConfig {
    targetSdkVersion 26
  }
  ...
}

dependencies {
  compile 'com.android.support:appcompat-v7:26.0.0-beta1'
}

// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
    maven {
        url 'https://maven.google.com'
        // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM