Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 979
arun Avatar asked Mar 05 '23 17:03

arun


1 Answers

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'
like image 144
laalto Avatar answered Mar 12 '23 20:03

laalto