Android studio 如何在本地将ok.io导入android studio?

Android studio 如何在本地将ok.io导入android studio?,android-studio,gradle,okio,android-module,Android Studio,Gradle,Okio,Android Module,我一直在尝试在我的项目中本地使用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/com

我一直在尝试在我的项目中本地使用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.
我原以为这是一条路,因为它说所有模块都需要具有相同的构建类型和风格。但这并没有带来什么不同

我的(应用程序)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')
    }
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 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')
    }
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'])
我的项目中的模块结构如下所示

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')
    }
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和/或“愉快”模块集成的任何建议。

请确保
include':okio'
存在于
settings.gradle
文件中。你有没有尝试过从给定链接发布的所有其他答案?是的,我已经更新了settings.gradle。