4

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?

arun
  • 1,418
  • 1
  • 13
  • 23

1 Answers1

9

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'
laalto
  • 144,748
  • 64
  • 275
  • 293
  • I was just about to figure the same out from: https://stackoverflow.com/questions/41506976/how-to-add-maven-dependency-android-studio – arun Jan 17 '19 at 06:23