我正在尝试构建一个本机应用程序,但它返回此错误:
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
> Could not find any version that matches androidx.appcompat:appcompat:28.+.
Versions that do not match:
- 1.1.0-rc01
- 1.1.0-beta01
- 1.1.0-alpha05
- 1.1.0-alpha04
- 1.1.0-alpha03
- + 10 more
Required by:
project :app
> Could not find any version that matches androidx.exifinterface:exifinterface:28.+.
Versions that do not match:
- 1.1.0-beta01
- 1.1.0-alpha01
- 1.0.0
- 1.0.0-rc02
- 1.0.0-rc01
- + 3 more
Required by:
project :app > project :react-native-camera
> Could not find any version that matches androidx.legacy:legacy-support-v4:28.+.
Versions that do not match:
- 1.0.0
- 1.0.0-rc02
- 1.0.0-rc01
- 1.0.0-beta01
- 1.0.0-alpha3
- + 1 more
Required by:
project :app > project :react-native-firebase
我的build.gradle
文件是:
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 23
compileSdkVersion = 28
targetSdkVersion = 26
supportLibVersion = "28.0.0"
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 "28.0.0"
}
}
}
afterEvaluate {
android {
compileSdkVersion 28
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
}
}
}
}
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "27.1.0"
}
这是我的应用级别build.gradle
文件
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.myapp.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
vectorDrawables.useSupportLibrary = true
versionCode 40
versionName "1.0.0"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'mlkit'
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-linear-gradient')
implementation project(':react-native-device-info')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-camera')
implementation project(':react-native-image-crop-picker')
implementation project(':rn-fetch-blob')
implementation project(':react-native-app-settings')
implementation project(':react-native-onesignal')
implementation project(':react-native-splash-screen')
implementation project(':react-native-orientation')
implementation project(':react-native-vector-icons')
implementation project(':react-native-firebase')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-basement:16.0.0'
implementation "com.google.firebase:firebase-core:16.0.6"
implementation "com.google.firebase:firebase-database:16.0.6"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
此外,我的Android Studio已下载了以下组件:
我是java / android的新手,所以不知道如何处理。
有人可以帮忙吗?
答案 0 :(得分:1)
您似乎已在使用AndroidX组件而未添加其依赖项。禁用AndroidX支持并使用较早的Android支持组件从XML文件中删除AndroidX组件,或者将以下依赖项添加到您现有的应用级build.gradle
文件中:
dependencies {
//...
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "androidx.exifinterface:exifinterface:1.0.0"
implementation "androidx.legacy:legacy-support-core-ui:1.0.0"
implementation "androidx.legacy:legacy-support-core-utils:1.0.0"
}
如果使用AndroidX,请重新检查gradle.properties
文件中是否包含这两行:
android.useAndroidX=true
android.enableJetifier=true
将这两个gradle插件标志设置为true意味着Android Plugin将使用适当的AndroidX库而不是支持Library并重写其二进制文件。要了解更多如何将整个项目迁移到AndroidX的信息,请点击以下链接: https://developer.android.com/jetpack/androidx/migrate