javascript - Android 依赖项有不同的版本 - 分辨率不起作用
问题描述
在我的 react-native 项目中,有 2 个使用 googles exoplayer 的包。一个使用 2.7.0 版本,而我现在尝试添加的一个使用 2.9.0。添加后我得到了
Android dependency 'com.google.android.exoplayer:exoplayer-core' has
different version for the compile (2.7.0) and runtime (2.9.2)
classpath. You should manually set the same version via
DependencyResolution
根据
我尝试添加
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.exoplayer'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "2.9.2"
}
}
}
}
到我的 /android/build.gradle
但现在我明白了
Could not resolve all files for configuration ':react-native-track-
player:debugCompileClasspath'.
> Could not find support-compat.jar (com.android.support:support-
compat:27.1.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-
compat/27.1.1/support-compat-27.1.1.jar
我想也许它应该使用 support-compat-28.0.0.jar 并添加
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "28.0.0"
}
但现在我明白了
error: failed linking references.
:app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.
实际上我不知道我在这里做什么,这是我第一次修改 gradle 文件......很想得到一些帮助
完整的 build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def keystorePropertiesFile = rootProject.file("./keystores/release.keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.example.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 51
versionName "0.0.51"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) {
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
repositories {
maven {
url 'http://repo.brightcove.com/releases'
}
}
dependencies {
compile project(':react-native-track-player')
compile project(':react-native-share')
compile project(':react-native-fs')
compile project(':react-native-check-notification-enable')
compile project(':react-native-passkit-wallet')
compile project(':rn-fetch-blob')
compile project(':react-native-orientation-locker')
compile project(':react-native-brightcove-player')
compile project(':react-native-vector-icons')
compile project(':react-native-onesignal')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"
implementation 'com.android.support:multidex:1.0.3'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf' ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
解决方案
推荐阅读
- javascript - 发布到 IIS 时未加载外部 Javascript 文件
- python - 从十六进制字符串表示创建原始 unicode 字符/输入单个反斜杠
- java - 使用java的keylistener按住并离开时空格键不注册
- regex - 使用 Regex 而不是 ImportXML 将 Google 搜索结果带入 Google 表格
- python - 使用弹性搜索和 python 提高性能
- javascript - 用于匹配包含一个单词并排除另一个单词的 URL 的正则表达式
- visual-c++ - 为什么我的重载构造函数会导致崩溃?
- c# - 为什么我从飞机上掉下来?
- java - 在循环运行时获取控制台读数
- ios - 无法在 iOS 模拟器上通过 Google 登录