Уже два печальных дня я пытался выпустить приложение React Native для Android, но получаю эту ошибку:
> Task :react-native-device-info:compileReleaseJavaWithJavac FAILED
/Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:368: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
^
symbol: variable P
location: class VERSION_CODES
/Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:370: error: cannot find symbol
locationEnabled = mLocationManager.isLocationEnabled();
^
symbol: method isLocationEnabled()
location: variable mLocationManager of type LocationManager
Note: /Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
Мой project/android/build.gradle
файл:
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 23
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
playServicesVersion = "16.0.0"
}
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenLocal()
google()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
afterEvaluate {
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
}
}
}
}
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.1.0"
}
Кроме того, в мою Android Studio загружены следующие компоненты:
- API 27
- API 28
- Инструменты сборки Android SDK 29
- Эмулятор Android
- Инструменты платформы Android SDK
- Инструменты Android SDK
- Репозиторий поддержки
Я несколько раз пытался очистить кеш-память, но безуспешно.
Я новичок в Java и не знаю, как с этим справиться.
Есть идеи?
После изменения compiledSdkVersion на 28, теперь я получаю следующие ошибки:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:releaseCompileClasspath'.
> Could not resolve android.arch.lifecycle:viewmodel:1.1.0.
Required by:
project :app
> Cannot find a version of 'android.arch.lifecycle:viewmodel' that satisfies the version constraints:
Dependency path 'MobileApp:app:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-fragment:28.0.0' --> 'android.arch.lifecycle:viewmodel:1.1.1'
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
> Could not find com.android.support:collections:27.1.1.
Required by:
project :app > com.android.support:appcompat-v7:28.0.0
project :app > com.android.support:support-compat:28.0.0
> Could not find com.android.support:cursoradapter:27.1.1.
Required by:
project :app > com.android.support:appcompat-v7:28.0.0
> Could not find com.android.support:loader:27.1.1.
Required by:
project :app > com.android.support:support-fragment:28.0.0
project :app > com.android.support:support-core-utils:28.0.0
> Could not resolve android.arch.lifecycle:viewmodel:1.1.1.
Required by:
project :app > com.android.support:support-fragment:28.0.0
> Cannot find a version of 'android.arch.lifecycle:viewmodel' that satisfies the version constraints:
Dependency path 'MobileApp:app:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-fragment:28.0.0' --> 'android.arch.lifecycle:viewmodel:1.1.1'
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
> Could not find com.android.support:versionedparcelable:27.1.1.
Required by:
project :app > com.android.support:support-compat:28.0.0
> Could not find com.android.support:documentfile:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
> Could not find com.android.support:localbroadcastmanager:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
> Could not find com.android.support:print:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
ОБНОВЛЕНИЕ 3
После изменения details.useVersion
на 28.0.0
я получаю эту ошибку:
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture fingerprint of input files for task ':app:bundleReleaseJsAndAssets' property '$1' during up-to-date check.
> Could not list contents of '/Users/myuser/myproject/node_modules/metro/node_modules/jest-haste-map/node_modules/.bin/sane'. Couldn't follow symbolic link.