Compiling with Ant "error: package org.apache.http does not exist"


#1

When I try to compile my project for android using ant I get these compilation errors when it gets to compiling the .java object in the androidActivityClass path:

error: package org.apache.http does not exist

                if (connection.getResponseCode() < org.apache.http.HttpStatus.SC_BAD_REQUEST)

error: package org.apache.http does not exist

            if (statusCode[0] >= org.apache.http.HttpStatus.SC_BAD_REQUEST)

I've been looking around at how to get ant to find the package. It's tough, as I'm completely new to using ant and the documenation I'm looking for seems to be eluding me. Anyway, I thought I'd post here in case I'm barking up the wrong tree. Any idea what I need to do to get it compiling? I don't really even understand why it's generating http code; it is just a text button with two toggle buttons.


#2

The android build tools are pretty horrible to install - our advice is that before you get as far as trying to compile any JUCE code, please get the Android NDK examples to build correctly on your machine. If that works, then the juce projects should do too, but really for problems like this one, Google is a better place to ask for help than here, as we don't claim to be experts on their toolchain.


#3

Hmm, that's part of the tricky part. The latest instructions for android compilation imply it should be done through Android Studio and gradle, while JUCE seems to assume it is still being done through Eclipse and Ant. As far as I can tell, the newest versions of Eclipse no longer support Android compilation.

 

Are there any plans to modify JUCE to work with Android Studio and gradle out-of-the-box?

 

--

 

As far as your advice, it looks to me like the NDK samples don't include a build.xml for compiling with ant. I'm not sure I even see the gradle files necessary. I'll dig into it some more. I see now that the plugin for Android development in Eclipse is still available. I'll see if acquiring that gives me the version of Ant that includes everything I need.


#4

So, I got Eclipse set up to compile JNI projects. I got two of the sample projects to compile and run on my phone. I imported the JUCE/Android build folder into an Eclipse project and added native support. When I try to compile, I get more or less the same warning on those same lines:

org.apache.http.HttpStatus cannot be resolved to a variable on line:

                if (connection.getResponseCode() < org.apache.http.HttpStatus.SC_BAD_REQUEST)


org.apache.http.HttpStatus cannot be resolved to a variable on line:

            if (statusCode[0] >= org.apache.http.HttpStatus.SC_BAD_REQUEST)

 

This is in the auto-generated (via JUCE) file in src/com.workspace.projectname/ProjectName.java


#5

This is fixed on the latest tip. Thank you for reporting.


#6

Excellent! Thanks for fixing this.