Solution 1 :
Apparently you cannot import org.nanohttpd.
The correct syntax is:
import fi.iki.elonen.NanoHTTPD.*;
Not sure if this is different from the nanohttpd github project…
Problem :
This is probably a really stupid question, but after messing with this for 2 hours, I cannot seem to resolve.
I am wanting to use nanohttpd in an android app as a lightweight local webserver. The gradle seems to find nanohttpd and builds just fine with the dependency; However, I cannot seem to include it in any of my java class files.
for example: I create a new class file and use:
import org.nanohttpd.protocols.http.response.Response;
I get the following error:
error: package org.nanohttpd.protocols.http.response does not exist
It also does not detect org.nanohttpd.* or even org.*
Below is my Gradle dependency line from the app level Gradle.build:
implementation group: 'org.nanohttpd', name: 'nanohttpd', version: '2.3.1'
This identifies current version and seems to work.
And here is the full Project level build.gradle
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.10"
classpath "org.nanohttpd:nanohttpd:2.3.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}