简体   繁体   English

Android Studio无法识别ShortcutManager类

[英]Android Studio not recognizing ShortcutManager class

I'm looking into shortcut creation with Android O. Unfortunately Android Studio is not recognizing the ShortcutManager class: 我正在研究使用Android O创建快捷方式。不幸的是,Android Studio无法识别ShortcutManager类:

在此输入图像描述

In the gradle file I have set as a dependency: 在gradle文件中,我将其设置为依赖项:

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

In the gradle file I have these versions set: 在gradle文件中我设置了以下版本:

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... 我已按照此SO响应中的步骤执行File => Invalidate Caches / Restart ...

Unfortunately Android Studio continues to not recognize the class. 不幸的是,Android Studio仍然无法识别该类。

Information on my version of Android Studio: 有关我的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 . 除了确保Android Studio版本号为2.3之外,我所获得的突破就是找到了迁移到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 . 在“获取Android O SDK”部分中,它规定了通过从Android Studio菜单工具> 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: 然后,您必须注意遵循“更新构建配置”一节中概述的构建配置所需的更新,我错过的元素是maven更新:

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/'
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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