问题
I have this error: Error
I think its happening because my SDK hasn't appcompat-v7:27.0.1 version. I dont know how add this version to my SDK. I need help!
My appcompat-v7 folder
I paste relevant code below. If you see the error elsewhere, tell me please!:
/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"
}
}
}
回答1:
Please clarify your issue,
If your compileSdkVersion is 23, You can not add that dependency.
Try one of these:
1. Install SDK Plaform 27 by selecting Tool > Android > SDK Manager> check Android API 27. next switch to SDK Tool>Show Package Details check one of the sdk build-tools version 27 and Apply
Then edit build.gradle: change compileSdkVersion to compileSdkVersion 27.
You should also change buildToolsVersion to "27.x.x" for example is buildToolsVersion '27.0.3'
OR
2. Try compile dependency com.android.support:appcompat-v7:27.0.1 to the version you are having.
You may want to see something here Android studio failed to build tools after updating to 3.0 from 2.3 stable channel
回答2:
I answered it with the next config:
/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'
}
}
}
}
Dont forget add string.xml and its corresponding in AndroidManifest.xml before executing:
cd android
gradlew clean
cd ..
react-native run-android
来源:https://stackoverflow.com/questions/48423374/how-do-i-add-appcompat-v727-0-1-to-sdk