plugins { id 'com.android.library' // 替换 application 插件 id 'maven-publish' // 添加发布插件 } android { namespace "com.tfq.library" compileSdkVersion 36 defaultConfig { minSdkVersion 24 targetSdkVersion 36 } buildTypes { release { } } // 添加 extractNativeLibs 配置 packagingOptions { jniLibs { useLegacyPackaging = true pickFirsts += '**/*.so' } } } dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' api 'androidx.appcompat:appcompat:1.7.0' api 'com.google.android.material:material:1.12.0' //gson api 'com.google.code.gson:gson:2.13.1' //okhttp api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.16' api 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.16' //图片加载 api 'com.github.bumptech.glide:glide:4.16.0' // Glide图形转换工具 api 'jp.wasabeef:glide-transformations:4.3.0' //高斯模糊效果 api 'com.github.centerzx:ShapeBlurView:1.0.5' // 吐司框架:https://github.com/getActivity/Toaster api 'com.github.getActivity:Toaster:12.8' //权限请求 api 'com.github.getActivity:XXPermissions:23.0' //RecyclerView api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.28' //沉浸式 api 'com.geyifeng.immersionbar:immersionbar:3.2.2' } afterEvaluate { publishing { publications { release(MavenPublication) { groupId = 'com.chuangketie.jk' artifactId = 'lib_base' version = rootProject.maven_version.version artifact("$buildDir/outputs/aar/${project.name}-release.aar") // 添加依赖传递配置 pom.withXml { def dependenciesNode = asNode().appendNode('dependencies') // 处理所有api配置的依赖 configurations.api.allDependencies.each { dep -> if (dep.group != null && dep.version != 'unspecified') { def dependencyNode = dependenciesNode.appendNode('dependency') dependencyNode.appendNode('groupId', dep.group) dependencyNode.appendNode('artifactId', dep.name) dependencyNode.appendNode('version', dep.version) } } } } } repositories { maven { url = "file://${projectDir.parent}/maven" } } } }