- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试开发一个小型库来将问题发布到我公司的 Jira 服务器,我认为带有 KTOR 的 Kotlin MPP将只是门票。
起初,按照一些教程,我做了一个共享项目,iOS 的导入工作正常,但 Android 的 Ktor 实现无法解决。然后我意识到我需要重新创建项目并创建一个库而不是共享应用程序,因为我已经为每个移动客户端拥有了现有的代码库,并且我需要发布 MPP 库以供他们使用。
将项目重新创建为库并开始添加 KTOR 1.3.2 的依赖项后,iOS 依赖项无法解决。这不仅仅是 KTOR,它是任何 iOS 依赖项,所以我的项目设置中显然有一些不正确的地方,但我无法发现它。
这是gradle文件:
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
}
repositories {
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
group 'com.example.issuereporter'
version '0.0.1'
apply plugin: 'maven-publish'
kotlin {
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios') {
binaries {
framework('IssueReporter')
}
}
fromPreset(presets.jvm, 'android')
}
def ktor_version = "1.3.2"
sourceSets["commonMain"].dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-json:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
}
sourceSets["commonTest"].dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
sourceSets["androidMain"].dependencies {
implementation kotlin('stdlib')
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "io.ktor:ktor-client-auth-jvm:$ktor_version"
}
sourceSets["androidTest"].dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
sourceSets["iosMain"].dependencies {
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-core-native:$ktor_version"
implementation "io.ktor:ktor-client-json-native:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
}
}
configurations {
compileClasspath
}
task packForXcode(type: Sync) {
final File frameworkDir = new File(buildDir, "xcode-frameworks")
final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
final def framework = kotlin.targets.ios.binaries.getFramework("IssueReporter", mode)
inputs.property "mode", mode
dependsOn framework.linkTask
from { framework.outputFile.parentFile }
into frameworkDir
doLast {
new File(frameworkDir, 'gradlew').with {
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
setExecutable(true)
}
}
}
tasks.build.dependsOn packForXcode
控制台输出是
Could not resolve io.ktor:ktor-client-ios:1.3.2.
Could not resolve io.ktor:ktor-client-core-native:1.3.2.
Could not resolve io.ktor:ktor-client-json-native:1.3.2.
Could not resolve io.ktor:ktor-client-serialization-native:1.3.2.
有什么明显我在这里失踪的吗?
build.gradle.kts
文件:
plugins {
kotlin("multiplatform") version "1.4.0"
kotlin("plugin.serialization") version "1.4.0"
id("com.android.library")
id("kotlin-android-extensions")
}
group = "com.example.issuereporter"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven(url = "https://kotlin.bintray.com/kotlinx")
maven(url = "https://dl.bintray.com/kotlin/ktor")
maven(url = "https://repo1.maven.org/maven2/")
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
maven(url = "https://plugins.gradle.org/m2/")
}
kotlin {
android()
iosX64("ios") {
binaries {
framework {
baseName = "library"
}
}
}
val ktor_version = "1.3.2"
val serialization_version = "0.20.0"
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-json:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
implementation("io.ktor:ktor-client-auth:$ktor_version")
implementation("io.ktor:ktor-client-apache:$ktor_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation("androidx.core:core-ktx:1.2.0")
implementation("io.ktor:ktor-client-android:$ktor_version")
implementation("io.ktor:ktor-client-auth-jvm:$ktor_version")
implementation("io.ktor:ktor-client-json-jvm:$ktor_version")
}
}
val androidTest by getting
val iosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:$ktor_version")
implementation ("io.ktor:ktor-client-core-native:$ktor_version")
implementation("io.ktor:ktor-client-json-native:$ktor_version")
implementation("io.ktor:ktor-client-auth-native:$ktor_version")
}
}
val iosTest by getting
}
}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
versionCode = 1
versionName = "1.0"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
当我设置
ktor_version
时,iOS 的 gradle 依赖项成功同步至
1.3.2
但不适用于
1.4.0
(假设镜像没有更新 native 文件??)...但是当我尝试使用该类时导入不会编译...见附图:
最佳答案
我猜你没有 enableFeaturePreview("GRADLE_METADATA")
在 settings.gradle
.
settings.gradle
查看我们的入门项目 KaMPKit对于 1.3.72 上的运行示例。我们可能会在本周将它升级到 1.4.0,但现在它应该是一个很好的引用。
关于android - 在 Kotlin MultiPlatform 项目中未解决 iOS 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63480511/
我将其添加到我的 build.gradle 文件中。 build.gradle compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' co
我按照 gamecodeschool.com 的教程制作了一个“Android 2D 滚动射击游戏”。 我遇到错误: "Cannot resolve symbol 'currentViewportWo
这是我的代码,createStoredProcedureQuery在eclipse下面有红线,并且没有解决,我尝试了很多方法仍然无法得到问题所在。 private static EntityManag
我正在 Xcode 6.1 中开发一个针对 iOS >= 7 的 Swift 应用程序,并且无法使用 NSStringDrawingUsesLineFragmentOrigin,因为它尚未解决。我用谷
使用 MSVC 2015 版本 14.0.25431.01 更新 3 .cpp 文件有 #include 项目属性中的 VC++ 包含路径是 $(VC_IncludePath);$(WindowsS
我使用 visual studio 2013 在 C 中编写程序,但出现此错误:MSVCRTD.lib(crtexe.obj):错误 LNK2019:函数 ___tmainCRTStartup 中引用
我正在编写一个更新到 Firebase 的应用程序,但我无法编写 oncancelled 函数,因为它无法解析符号 FirebaseError。 我的代码如下: package com.test.my
我不明白为什么这没有解决,有什么想法吗? “resolve this”确实会打印,但它永远不会回到 .then 中 promise 的解决方案。 var promise = wait(); promi
我在 eclipse/java 中使用 mapView 时遇到以下问题。 使用mapView.getOverlays()我收到错误。 mapView cannot be resolved 我尝试对 m
你能告诉我如何用两组 R.drawable.images 盗版创建 if - else 语句吗? 我已经尝试过,但我收到一个错误代码,提示 pirates is un-resolved。 Bitmap
我关注了this link大多数结果的答案给我的方法 setOnGroupExpandListener 无法解析。我是 android 的新手,目前主要通过查看其他人的做法并尝试向他们学习来做一些事情
import React from 'react'; // import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom/dist
我正在 eclipse(版本 3.6.2)中开发一个 android 应用程序,我刚刚添加了以下内容: 导入 android.webkit.GeolocationPermissions; 但是我得到一
我的网站上有多个视频需要播放()。当 play() 返回一个 Promise 时,我使用 Promise.all() 创建了一个小脚本,因此每个 Promise 都会等待其他 Promise。 try
我们将所有已编译的程序集复制到构建后步骤中的一个输出文件夹中 (d:\c\bin\assemblies)。使用 Windows 和 Microsoft .NET 框架,可以在编译时使用指向该输出文件夹
我有一个数据库查找查询,它返回 150k 个文档,其中每个文档包含三个整数字段和一个日期时间字段。以下代码尝试从游标对象创建列表。迭代光标非常慢——大约 80 秒!通过 C++ 驱动程序执行相同的操作
我想使用 View Pager2 实现 Carousel,像这样预览左右页面: 最初我使用的是支持的view pager1。现在我认为它被删除了 viewPagerhost.setPageMa
我正在 android 中启动基于 Ktor 的客户端,我想使用任何序列化程序,目前,来自 kotlinx 的序列化程序,但其他序列化程序的结果是相同的 - 未找到 JsonFeature(在下面的
我一直被一个 Unresolved 问题所困扰 'R_registerRoutines', 'R_useDynamicSymbols'来自 R CMD 检查的注释。我已经阅读了“Writing R E
我不确定,但我无法用我的生命来解决这个问题。它总是悬而未决。我不是最擅长 promise 的人,所以请帮助我。 export async function getQuotes() { const
我是一名优秀的程序员,十分优秀!