我一直在尝试在我的项目中本地使用ok.io(1.14.1版),并且在满足gradle要求方面进行了相当大的努力。我的项目要求我在本地包含源。我已经成功导入了模块,但是当尝试运行构建时,我最终遇到此错误
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :okio.
我曾以为this solution是要走的路,因为它说所有模块都必须具有相同的构建类型和风格。但这并没有改变。
我的(应用程序)build.gradle看起来像这样
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.some.app.id"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {}
}
productFlavors {
}
compileOptions {
targetCompatibility 1.7
sourceCompatibility 1.7
}
}
dependencies {
.....
implementation project(path: ':okio')
}
ok.io build.gradle看起来像这样
import com.github.jengelman.gradle.plugins.shadow.transformers.DontIncludeResourceTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.IncludeResourceTransformer
apply plugin: 'java-library'
apply plugin: 'org.jetbrains.kotlin.platform.jvm'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'me.champeau.gradle.japicmp'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'me.champeau.gradle.jmh'
apply from: "$rootDir/gradle/gradle-mvn-push.gradle"
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
jar {
manifest {
attributes('Automatic-Module-Name': 'okio')
}
}
animalsniffer {
sourceSets = [sourceSets.main]
}
configurations {
baseline
}
jmhJar {
def excludeAllBenchmarkLists = new DontIncludeResourceTransformer()
excludeAllBenchmarkLists.resource = "META-INF/BenchmarkList"
transform(excludeAllBenchmarkLists)
def includeCorrectBenchmarkList = new IncludeResourceTransformer()
includeCorrectBenchmarkList.resource = "META-INF/BenchmarkList"
includeCorrectBenchmarkList.file = new File("$rootDir/okio/jvm/build/classes/java/jmh/META-INF/BenchmarkList")
transform(includeCorrectBenchmarkList)
}
jmh {
// The JMH plugin currently requires the Shadow plugin also be installed.
// See: https://github.com/melix/jmh-gradle-plugin/issues/97#issuecomment-374866151
include = ['com\\.squareup\\.okio\\.benchmarks\\.SelectBenchmark.*']
duplicateClassesStrategy = 'warn'
}
dependencies {
signature 'org.codehaus.mojo.signature:java16:1.1@signature'
expectedBy project(':okio')
implementation deps.kotlin.stdLib.jdk6
compileOnly deps.animalSniffer.annotations
compileOnly deps.jsr305
testImplementation deps.test.junit
testImplementation deps.test.assertj
testImplementation deps.kotlin.test.jdk
baseline('com.squareup.okio:okio:1.14.1') {
transitive = false
force = true
}
jmh deps.jmh.core
jmh deps.jmh.generator
}
task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: 'jar') {
oldClasspath = configurations.baseline
newClasspath = files(jar.archivePath)
onlyBinaryIncompatibleModified = true
failOnModification = true
txtOutputFile = file("$buildDir/reports/japi.txt")
ignoreMissingClasses = true
includeSynthetic = true
classExcludes = [
'okio.SegmentedByteString', // internal
'okio.Util', // internal
]
methodExcludes = [
'okio.ByteString#getByte(int)', // became 'final' in 1.15.0
'okio.ByteString#size()', // became 'final' in 1.15.0
]
}
check.dependsOn(japicmp)
assemble.dependsOn(tasks['jmhJar'])
我项目中模块的结构如下
任何有关如何在本地集成ok.io和/或“快乐”模块集成的建议都将受到赞赏。