androidgradledependenciesimplementationandroid-build

implementation error in android studio gradle


I'm android beginner I want to imlementation file in 'top.fighter-lee:mqttlibs:1.0.1'(github) but I got error.

Is there any solution? and I would like to know the cause of the error. It said it couldn't find this file. Then, is this top.finghter-lee:mqttlibs:1.0.1 no longer in service?

I apologize in advance for my lack of English skills.

Build Output monitor

> Task :app:clean
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :app:checkDebugAarMetadata FAILED
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:mergeDebugResources FAILED
> Task :app:packageDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:parseDebugLocalResources
> Task :app:extractDeepLinksDebug
> Task :app:processDebugMainManifest FAILED
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets FAILED
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:mergeDebugJavaResource FAILED
> Task :app:checkDebugDuplicateClasses FAILED
> Task :app:desugarDebugFileDependencies FAILED
> Task :app:mergeDebugJniLibFolders
> Task :app:mergeDebugNativeLibs FAILED
> Task :app:validateSigningDebug
> Task :app:writeDebugAppMetadata
> Task :app:writeDebugSigningConfigVersions

FAILURE: Build completed with 8 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find top.fighter-lee:mqttlibs:1.0.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/top/fighter-lee/mqttlibs/1.0.1/mqttlibs-1.0.1.pom
       - https://repo.maven.apache.org/maven2/top/fighter-lee/mqttlibs/1.0.1/mqttlibs-1.0.1.pom
     Required by:
         project :app

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================



* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 31s
21 actionable tasks: 21 executed

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}

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

buildgradle

plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.mqtttest01"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation **'top.fighter-lee:mqttlibs:1.0.1'**
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

I want to use api in top.fighter-lee:mqttlibs:1.0.1'(github)


Solution

  • According to MVN repository site, the library you're referring to is stored in the Spring Plugins repository at https://repo.spring.io/plugins-release/.

    This means that you have to add the following section in your root project's build.gradle file:

    buildscript {
        repositories {
            maven { url 'https://repo.spring.io/plugins-release/' }
        }
    }
    

    If you now rebuild the project, the library can be downloaded successfully.

    Depending on how you structured your project you can even add the maven statement in the settings.gradle file:

    pluginManagement {
        repositories {
            gradlePluginPortal()
            google()
            mavenCentral()
            maven { url 'https://repo.spring.io/plugins-release/' }
        }
    }
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url 'https://repo.spring.io/plugins-release/' }
        }
    }
    

    Hope this helps