我们有一个项目,除了我之外,每个人都可以编译和运行。我有完全相同的代码,我尝试以完全相同的方式运行它,但是日志显示:
失败:构建失败,并出现异常。
- 出了什么问题:无法解析配置':react-native-camera:debugCompileClasspath'的所有文件。
>找不到core.jar(com.google.zxing:core:3.3.0)。在以下位置搜索: https://artifactory.mycompany.eu/artifactory/mvn-libs-all/com/google/zxing/core/3.3.0/core-3.3.0.jar
我更改了上面的网址(仅更改了公司名称),但我检查了一下,然后将jar显示在其中。
这个jar是react-native-camera节点模块所必需的。
我已经:
但是没有任何帮助。
编辑:
project / build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
rootProject.ext.isRelease = project.hasProperty('buildForDebug')? false:true
def RNfile = new File("$rootDir/node_modules/react-native/package.json")
rootProject.ext.rnVersion = new groovy.json.JsonSlurper().parseText(RNfile.text).version
artifactId = project.artifactId
allprojects {
println "release $isRelease"
//version = "${project.version}-${isRelease ? project.property('build.number') : 'SNAPSHOT'}"
version = "${project.version}-${ project.hasProperty('build.number') ? project.property('build.number') : '0'}"
group = project.groupId
println "coordinates: $group:$artifactId:$version"
}
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion rootProject.ext.rnVersion
}
}
}
}
repositories {
mavenLocal()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/node_modules/react-native/android"
}
}
}
subprojects { project ->
afterEvaluate {
if (project.name.contains('react-native-')) {
project.tasks.collect { task ->
if (task.name == 'lint') {
task.enabled = false
}
}
}
}
}
project / android / app / build.gradle
project.ext.androidSignKeystorePassword = (project.hasProperty('keystorePassword'))? project.property('keystorePassword') : System.properties['android.keystorePassword']
project.ext.androidSignKeyPassword = (project.hasProperty('keyPassword'))? project.property('keyPassword') : System.properties['android.keyPassword']
project.ext.androidSignKeyAlias = (project.hasProperty('keyAlias'))? project.property('keyAlias') : System.properties['android.keyAlias']
configurations {
keystore
}
dependencies {
keystore "eu.dorsum.cm.config:jenkins-android-keystore:1@jks"
}
rootProject.ext.signApp = project.hasProperty('signKeyAlias') && project.hasProperty('keystore-android-password')
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
mavenLocal()
google()
maven {
url "https://maven.google.com"
}
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/'
name 'Google'
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion rootProject.ext.rnVersion
}
}
}
}
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
import com.android.build.OutputFile
project.ext.react = [
root: "$rootDir",
entryFile: "index.js"
]
apply from: "$rootDir/node_modules/react-native/react.gradle"
apply from: "$rootDir/node_modules/react-native-vector-icons/fonts.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 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.dbit"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName project.version
ndk {
abiFilters "armeabi-v7a", "x86"
}
if (!project.hasProperty('buildForDebug')) {
archivesBaseName = "${rootProject.name}-${versionName}"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
storeFile files(project.configurations.keystore.collect { it }).singleFile
storePassword project.ext.androidSignKeystorePassword
keyAlias project.ext.androidSignKeyAlias
keyPassword project.ext.androidSignKeyPassword
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}
variantFilter { variant ->
// ignores unwanted build types
// no release type from development branch, no debug type from release branch
// (ignore = release type XOR release version)
setIgnore(variant.buildType.name.equals('release') ^ isRelease)
}
// 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
}
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation project(':react-native-view-overflow')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-fcm')
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-messaging'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.0.3"
implementation "com.facebook.react:react-native:${rootProject.ext.rnVersion}" // From node_modules
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
implementation 'com.android.support:exifinterface:27.1.0'
implementation ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
}
// 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.implementation
into 'libs'
}
如果您有任何建议,将不胜感激。
答案 0 :(得分:0)
我认为您错过了Gradle中的存储库以获取com.google.zxing:core:3.3.0
您需要打开Android Studio,并在本机项目的文件夹/android
中打开项目。
并编辑项目的文件build.gradle
并将google()
和jcenter()
添加到respository
和buildscript
的{{1}}
像这样
allprojects
答案 1 :(得分:0)
就我而言,解决方案在projectName / android文件夹中运行以下命令:
gradlew cleanBuildCache
对我来说奇怪的是,清洁干净还不够。
根据本文档https://developer.android.com/studio/build/build-cache#clear_the_build_cache:
“类似于Android插件的清除任务,该任务清除了您项目的 build /目录,您可以运行cleanBuildCache任务来清除您的 项目的构建缓存。”
基于此信息,很明显我的构建缓存中出了点问题,并导致了问题。
我还必须删除node_modules文件夹,然后重新安装所有节点模块。