androidandroid-gradle-pluginnanohttpd

NanoHTTPD - unable to add gradle dependency


I am trying to add NanoHTTPD to my Android project.

As mentioned in README.md, I added

dependencies {
    runtime(
       [group: 'org.nanohttpd', name: 'nanohttpd', version: '2.3.1'],
    )
}

it is giving error:

Could not find method runtime() for arguments [{group=org.nanohttpd, name=nanohttpd, version=2.3.1}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I also tried adding

repositories {
    mavenCentral()
}

mentioned elsewhere, but same error.

I tried the usual way:

implementation 'org.nanohttpd.nanohttpd:2.3.1'

it gives error:

Failed to resolve: org.nanohttpd.nanohttpd:2.3.1:

I am using Android Studio 3.2.1 There seem to be so many people happily using it in Android. What am I missing?


Solution

  • In your gradle file, separate group and artifact ids with a : instead of .. That is, replace

    implementation 'org.nanohttpd.nanohttpd:2.3.1'
    

    with

    implementation 'org.nanohttpd:nanohttpd:2.3.1'