config.json
{
"minSdkVersion": "23",
"dependencies": [
"com.github.mik3y:usb-serial-for-android:3.10.0"
],
"project": {
"dependencies": [
"com.github.mik3y:usb-serial-for-android:3.10.0"
]
}
}
uni_modules/demo-plugin/utssdk/app-android里面写了个Demo.kt
package uts.sdk.modules.demoPlugin
import android.content.Context
import android.hardware.usb.UsbManager
import com.hoho.android.usbserial.driver.UsbSerialPort
import com.hoho.android.usbserial.driver.UsbSerialProber
import com.hoho.android.usbserial.util.HexDump
import com.hoho.android.usbserial.util.SerialInputOutputManager
import io.dcloud.uts.UTSAndroid
import io.dcloud.uts.console
运行报错
uni_module [demo-plugin] 正在更新三方依赖...
17:53:02.557 uni_module [demo-plugin]
17:53:02.557 FAILURE: Build failed with an exception.
17:53:02.557 * What went wrong:
17:53:02.557 Execution failed for task ':androidDependencies'.
17:53:02.557 > Could not resolve all artifacts for configuration ':debugCompileClasspath'.
17:53:02.557 > Could not resolve all dependencies for configuration ':debugCompileClasspath'.
17:53:02.558 > Could not find com.github.mik3y:usb-serial-for-android:3.10.0.
17:53:02.558 Required by:
17:53:02.558 root project :
17:53:02.559 * Try:
17:53:02.559 > The project declares repositories, effectively ignoring the repositories you have declared in the settings.
17:53:02.559 To determine how project repositories are declared, configure your build to fail on project repositories.
17:53:02.559 For more information, please refer to https://docs.gradle.org/8.14.4/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories in the Gradle documentation.
17:53:02.559 > Run with --stacktrace option to get the stack trace.
17:53:02.560 > Run with --info or --debug option to get more log output.
17:53:02.560 > Run with --scan to get full insights.
17:53:02.560 > Get more help at https://help.gradle.org.
17:53:02.560 BUILD FAILED in 1m 22s
17:53:14.737 uts插件[demo-plugin]编译失败
17:53:14.738 error: 找不到名称“hoho”。参考: https://doc.dcloud.net.cn/uni-app-x/uts/compiler-known-issues.html#error18
com.hoho是在com.github.mik3y:usb-serial-for-android:3.10.0这个依赖里的,这个包存在但却下载不下来。
2 个回复
Ask小助手
该问题是因为缺少 JitPack 仓库配置导致 Gradle 无法解析
com.github.mik3y:usb-serial-for-android依赖。解决方案:
在
config.json的project.repositories中添加 JitPack 仓库地址:原因说明:
com.github.mik3y:usb-serial-for-android托管在 JitPack 上,默认情况下 UTS 插件的 Gradle 配置不包含 JitPack 仓库,因此会报Could not find错误。根据 UTS 插件配置文档,需要在project.repositories中显式声明该仓库。补充建议:
如果仅需使用 USB 串口功能,建议直接使用插件市场已有的封装插件,无需自行封装:
这些插件已处理好依赖配置和原生接口封装,可直接使用。
低调路人甲 (作者)
加了 JitPack仓库地址依赖报错
要回复问题请先登录或注册
公告
更多>相关问题