我有这个错误:Error
我认为它的发生是因为我的SDK没有appcompat-v7:27.0.1版本。我不知道如何将此版本添加到我的SDK中。我需要帮助!
我粘贴下面的相关代码。如果你在其他地方看到错误,请告诉我!:
/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"
}
}
}
答案 0 :(得分:0)
请澄清您的问题,
如果您的compileSdkVersion为23,则无法添加该依赖项
尝试其中一种:
1.选择Tool
>安装SDK Plaform 27。 Android
> SDK Manager
>检查Android API 27.然后切换到SDK Tool
> Show Package Details
检查其中一个sdk build-tools版本27和Apply
然后编辑build.gradle:将compileSdkVersion更改为compileSdkVersion 27
。
您还应该将buildToolsVersion更改为“27.x.x”,例如buildToolsVersion '27.0.3'
OR
2.尝试将依赖项com.android.support:appcompat-v7:27.0.1
编译为您拥有的版本。
您可能希望在此处看到Android studio failed to build tools after updating to 3.0 from 2.3 stable channel
答案 1 :(得分:-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