Android库申请Jcenter(Bintray)审核未通过,求助解决方法
Hey there! I've run into this exact snag when uploading my first Android library to Bintray, so let's break down what's going on and how to fix it.
Why You Got That Email
Bintray's JCenter team requires all essential library files (.aar, .pom, sources jar, javadoc jar, etc.) to live in the same directory path within your Bintray repo. Right now, your files are probably scattered across different folders—like build variant directories, or nested paths that don't follow the standard Maven structure—which is why they're asking you to consolidate them.
Step-by-Step Fix
1. Verify Your Bintray File Structure
First, log into your Bintray account and navigate to your SharedPref library. Check if your files are organized like this (the correct structure):
maven/SharedPref/com/hitanshu/SharedPref/1.0.0/ ├─ SharedPref-1.0.0.aar ├─ SharedPref-1.0.0.pom ├─ SharedPref-1.0.0-sources.jar └─ SharedPref-1.0.0-javadoc.jar
If instead you see files split into different folders (like debug/ vs release/, or no nested groupId/artifactId/version structure), that's the root problem.
2. Fix Your build.gradle Configuration
Most likely, your upload task isn't configured to package and upload all files to the same standard Maven path. Below is a corrected, standard configuration using the bintray and maven-publish plugins (replace placeholder values with your own):
apply plugin: 'com.android.library' apply plugin: 'com.jfrog.bintray' apply plugin: 'maven-publish' android { compileSdkVersion 30 // Use your target SDK version defaultConfig { minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } // Define your library coordinates def groupId = "com.hitanshu" def artifactId = "SharedPref" def versionName = "1.0.0" // Generate sources and javadoc jars (required for JCenter) task sourceJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier "sources" } task javadocJar(type: Jar) { from javadoc.destinationDir classifier "javadoc" } // Configure Maven publication publishing { publications { maven(MavenPublication) { groupId groupId artifactId artifactId version versionName // Attach the release AAR artifact("$buildDir/outputs/aar/${artifactId}-release.aar") // Attach sources and javadoc artifact sourceJar artifact javadocJar // Generate a proper POM file with dependencies pom.withXml { def dependenciesNode = asNode().appendNode('dependencies') configurations.implementation.allDependencies.each { dep -> if (dep.group != null && dep.name != null && dep.version != null) { def dependencyNode = dependenciesNode.appendNode('dependency') dependencyNode.appendNode('groupId', dep.group) dependencyNode.appendNode('artifactId', dep.name) dependencyNode.appendNode('version', dep.version) } } } } } } // Configure Bintray upload bintray { user = System.getenv("BINTRAY_USER") // Use env vars for security, or hardcode (not recommended) key = System.getenv("BINTRAY_KEY") publications = ["maven"] // Match the publication name above pkg { repo = "maven" // Your Bintray repo name name = "SharedPref" // Your library name in Bintray desc = "A simple SharedPreferences wrapper for Android" // Add a description licenses = ["Apache-2.0"] // Choose a valid open-source license vcsUrl = "https://github.com/your-username/SharedPref.git" // Link to your repo version { name = versionName desc = "Initial release of SharedPref library" } } }
3. Clean Up and Re-Upload
- First, delete the existing scattered files from your Bintray
SharedPreflibrary (you can do this directly in the Bintray web interface). - Run these commands in your project root to build and re-upload:
./gradlew clean build sourceJar javadocJar bintrayUpload - Double-check in Bintray that all files are now in the same
groupId/artifactId/versionpath.
4. Re-Submit JCenter Request
Once your files are properly consolidated, go back to Bintray and re-submit your JCenter linking request. The team should approve it quickly now!
内容的提问来源于stack exchange,提问作者H D

