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

Android集成第三方SDK遇Gradle 'Already seen doctype'同步错误求助

解决Android集成第三方SDK时的"Already seen doctype"同步错误

我首次在Android项目中集成第三方SDK,已将SDK放置在app/libs目录,但项目同步时持续出现"Already seen doctype"错误。以下是我的项目配置文件:

项目级(build.gradle)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.6.21'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://purelive.jfrog.io/artifactory/main"
            credentials {
                username ''
                password ''
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级(build.gradle)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}
apply plugin: 'kotlin-android'

android {
    namespace 'com.implementation.efr'
    compileSdk 33

    defaultConfig {
        applicationId "com.implementation.efr"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            debuggable false
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            debuggable true
            //shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.7.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.7.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation(name:'mfl-4.1.9', ext:'aar')
    implementation 'com.pure.live:sdk:6.3.6.1'
    implementation 'androidx.exifinterface:exifinterface:1.3.6'
}

settings.gradle

rootProject.name = "EFR"
include ':app'

解决建议

"Already seen doctype"错误一般是Gradle解析Maven仓库返回的XML内容时遇到重复DOCTYPE声明导致的,常见原因及处理方案如下:

  • 检查私有仓库凭证:你配置的https://purelive.jfrog.io/artifactory/main仓库目前凭证为空,空凭证可能导致仓库返回未授权的HTML页面(而非合法的Maven元数据XML),引发解析错误。请填写正确的username和password后重试。
  • 临时隔离私有仓库:将项目级build.gradle中的私有maven块注释掉,重新同步项目。如果错误消失,说明问题确实出在该私有仓库的配置或访问上,可进一步排查仓库地址、权限或网络问题。
  • 验证本地SDK文件完整性:确认app/libs下的mfl-4.1.9.aar文件未损坏,可重新下载替换后尝试同步。损坏的aar包可能包含异常的元数据XML。
  • 清理Gradle缓存:执行命令:
    ./gradlew clean build --refresh-dependencies
    
    清除本地缓存的依赖数据,避免缓存的错误XML持续影响同步。
  • 排查依赖冲突:检查com.pure.live:sdk:6.3.6.1和本地aar是否存在依赖冲突,尤其是涉及XML解析的库(如org.xmlpull相关依赖)。可通过./gradlew app:dependencies查看依赖树,找出重复依赖并排除。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 21:30:38