You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Android Studio中添加GitHub第三方库遇问题求助

解决MathView与KatexView库的添加问题

一、MathView库(版本不存在错误)

  • 确认依赖配置方式
    该库未在Maven Central发布正式版本,需通过JitPack拉取GitHub仓库代码。先在项目根目录的settings.gradle(或settings.gradle.kts)中添加JitPack仓库:
    dependencyResolutionManagement {
        repositories {
            // 保留原有仓库,新增如下配置
            maven { url 'https://jitpack.io' }
        }
    }
    
    然后在模块的build.gradle中使用最新Commit哈希作为版本号(去项目GitHub的commits列表复制最新的哈希值替换示例中的xxxxxx):
    dependencies {
        implementation 'com.github.jianzhongli:MathView:xxxxxx'
    }
    
  • 同步与清理缓存
    点击Android Studio的Sync Now按钮同步项目,若仍报错,执行File -> Invalidate Caches... -> Invalidate and Restart清理缓存后重试。

二、KatexView库(Could not resolve all files错误)

  • 检查仓库与依赖版本
    确保JitPack仓库已配置(步骤同上),然后在模块build.gradle中添加对应稳定版本的依赖:
    dependencies {
        implementation 'com.github.judemanutd:KatexView:1.6.0'
    }
    
  • 适配AndroidX与解决冲突
    若项目已迁移到AndroidX,在gradle.properties中确保以下配置开启:
    android.useAndroidX=true
    android.enableJetifier=true
    
    若存在依赖冲突,可尝试排除冲突模块:
    implementation('com.github.judemanutd:KatexView:1.6.0') {
        exclude group: 'com.android.support'
    }
    
  • 排查网络问题
    若仍无法解析,检查是否代理或网络限制导致无法拉取依赖,可暂时关闭代理,或添加阿里云镜像仓库辅助拉取:
    maven { url 'https://maven.aliyun.com/repository/public' }
    

内容的提问来源于stack exchange,提问作者user17765346

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 15:24:23