如何将 appcompat-v7:27.0.1 添加到 SDK?

How do I add appcompat-v7:27.0.1 to SDK?

我有这个错误:Error

我认为这是因为我的 SDK 没有 appcompat-v7:27.0.1 版本。我不知道如何将此版本添加到我的 SDK。我需要帮助!

My appcompat-v7 folder

我把相关代码贴在下面。如果您在其他地方看到错误,请告诉我!:

/app/build.gradle

  android {
      compileSdkVersion 23
      buildToolsVersion "23.0.1"

      defaultConfig {
          applicationId "com.reactnavigationdrawer"
          minSdkVersion 16
          targetSdkVersion 22
          versionCode 1
          versionName "1.0"
          ndk {
              abiFilters "armeabi-v7a", "x86"
          }
      }
      ...
 }
  dependencies {
      compile project(':react-native-vector-icons')
      compile fileTree(dir: "libs", include: ["*.jar"])
      compile "com.android.support:appcompat-v7:27.0.1"
      compile "com.facebook.react:react-native:+"  // From node_modules
      compile 'com.facebook.android:facebook-android-sdk:+'
  }

build.gradle

  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.2.3'

          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }

  allprojects {
      repositories {
          mavenLocal()
          jcenter()
          mavenCentral()
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url "$rootDir/../node_modules/react-native/android"
          }
      }
  }

请澄清您的问题,
如果你的compileSdkVersion是23,你可以不添加那个依赖。
尝试其中之一:
1. 安装 SDK Plaform 27 选择 Tool > Android > SDK Manager> 检查 Android API 27. 接下来切换到 SDK Tool>Show Package Details 检查其中一个 sdk 构建工具版本 27 和 Apply
然后编辑 build.gradle:将 compileSdkVersion 更改为 compileSdkVersion 27。 您还应该将 buildToolsVersion 更改为“27.x.x”,例如 buildToolsVersion '27.0.3'

2. 尝试将依赖项 com.android.support:appcompat-v7:27.0.1 编译到您拥有的版本。

你可能想在这里看到一些东西

我用下一个配置回答了它:

/app/build.gradle

     android {
      compileSdkVersion 27
      buildToolsVersion "27.0.1"

      defaultConfig {
          applicationId "com.reactnavigationdrawer"
          minSdkVersion 16
          targetSdkVersion 22
          versionCode 1
          versionName "1.0"
          ndk {
              abiFilters "armeabi-v7a", "x86"
          }
      }
      signingConfigs {
         release {
             storeFile file(MYAPP_RELEASE_STORE_FILE)
             storePassword MYAPP_RELEASE_STORE_PASSWORD
             keyAlias MYAPP_RELEASE_KEY_ALIAS
             keyPassword MYAPP_RELEASE_KEY_PASSWORD
         }
     }
     ...
    dependencies {
      compile project(':react-native-vector-icons')
      compile fileTree(dir: "libs", include: ["*.jar"])
      compile "com.android.support:appcompat-v7:+"
      compile "com.facebook.react:react-native:+"  // From node_modules
      compile(project(':react-native-fbsdk')) {
       exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
      }
      compile('com.facebook.android:facebook-android-sdk:4.22.1')
   }

build.gradle

  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.2.3'

          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }

  allprojects {
      repositories {
          mavenLocal()
          jcenter()
          mavenCentral()
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url "$rootDir/../node_modules/react-native/android"
          }
          maven {url"https://maven.google.com"}
          configurations.all {
              resolutionStrategy {
                  force 'com.facebook.android:facebook-android-sdk:4.22.1'
              }
          }
      }
  }

执行前不要忘记在AndroidManifest.xml中添加string.xml及其对应的:

cd android

gradlew clean

cd ..

react-native run-android