Bug 1407 : "taskdef class com.android.ant.SetupTask cannot be found" when starting on running Android sketches on Linux
Last modified: 2009-12-06 11:28




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
ac
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-12-03 17:19
Android mode starts ok (using latest code from svn, on ubuntu 9.04). But
when hitting the run button I get (for any sketch):

taskdef class com.android.ant.SetupTask cannot be found

The android emulator starts, but doesnt seem to show any processing-related
sketch. The console dump is the following:

emulator -avd Processing-Donut -port 5566 -no-boot-anim

java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at processing.core.PApplet.saveStream(PApplet.java:4385)
at processing.app.tools.android.Build.writeLibs(Build.java:523)
at processing.app.tools.android.Build.createProject(Build.java:148)
at processing.app.tools.android.Android$RunHandler.run(Android.java:757)
at java.lang.Thread.run(Thread.java:619)

BUILD FAILED
/home/andres/Devel/Processing/svn/trunk/build/linux/work/examples/Topics/Animation/AnimatedSprite/android/build.xml:15:
taskdef class com.android.ant.SetupTask cannot be found

Total time: 0 seconds
/home/andres/Devel/Processing/svn/trunk/build/linux/work/examples/Topics/Animation/AnimatedSprite/android/build.xml:15:
taskdef class com.android.ant.SetupTask cannot be found
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:609)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
at processing.app.tools.android.Build.antBuild(Build.java:238)
at processing.app.tools.android.Android$RunHandler.run(Android.java:761)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: com.android.ant.SetupTask
at
org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1324)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1072)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
... 13 more
--- Nested Exception ---
java.lang.ClassNotFoundException: com.android.ant.SetupTask
at
org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
at
Additional Comment #1 From fry 2009-12-04 14:14
have you removed the work folder and done ./make.sh again since the recent
updates?
Additional Comment #2 From ac 2009-12-05 11:21
mmm.... I updated to the latest revision in the svn, deleted linux/work and
did ./make.sh again.

But the problem persists:

/home/andres/Devel/Processing/svn/trunk/build/linux/work/examples/Basics/Color/Brightness/android/build.xml:15:
taskdef class com.android.ant.SetupTask cannot be found

There is also the exception:

Java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at processing.core.PApplet.saveStream(PApplet.java:4385)
at processing.app.tools.android.Build.writeLibs(Build.java:523)
at processing.app.tools.android.Build.createProject(Build.java:148)
at processing.app.tools.android.Android$RunHandler.run(Android.java:757)
at java.lang.Thread.run(Thread.java:619)


Not sure if both are related.

Could the "com.android.ant.SetupTask cannot be found" error happen because
an installation problem (some component from the android sdk missing)?
Right now I'm checking if I have all the required components installed...
Additional Comment #3 From fry 2009-12-05 14:33
it means that ant-launcher.jar isn't being found (or maybe ant.jar, but i
think it's ant-launcher.jar). trying to find out why it's not being copied now.
Additional Comment #4 From fry 2009-12-05 15:19
huh, i'm not getting the SetupTask issue, though i'm seeing a problem with
it not being able to find processing.android.core, which i need to fix.
i'll keep looking into it.
Additional Comment #5 From fry 2009-12-05 17:27
Oh! I missed that this was the /android/ SetupTask that was missing. Right,
so that's an improperly installed SDK. What parts of the SDK have you
installed? Did you follow the full instructions?
Additional Comment #6 From ac 2009-12-05 18:15
I'm using the latest android SDK for linux (android-sdk_r04-linux_86), with
the following packages installed:

* Android SDK Tools, revision 4
* SDK Platform Android 1.6, API 4, revision 2
* SDK Platform Android 2.0, API 5, revision 1
* Google APIs by Google Inc., Android API 4, revision 2
* Google APIs by Google Inc., Android API 5, revision 1

I followed the installation steps listed in
http://developer.android.com/sdk/index.html, with the exception of #2
(installation of ADT plugin for Eclipse). I didn't try the Hello World
example for Eclipse either, but I'll do this next, to make sure that the
SDK is working fine from Eclipse.
Additional Comment #7 From fry 2009-12-05 18:18
that's really odd. have you set ANDROID_SDK in your .bashrc or .profile?
and have you added to the tools to your PATH? (you shouldn't need to, but...)
Additional Comment #8 From ac 2009-12-05 18:37
Ok, I was aware of the "export PATH=blahblah" in the .bashrc file (read it
in the android installation guide), but not of exporting the ANDROID_SDK
environmental variable, which I just did...

However, still getting this "com.android.ant.SetupTask not found" error.
Weird... I'll do some testing from Eclipse and update soon...
Additional Comment #9 From fry 2009-12-05 18:39
right, you shouldn't need to set either, since Processing will take care of
them, but i'm trying to figure out why it's not finding those libraries.

i tried the install on a clean ubuntu 9.10 install and it was ok, just
using the instructions. not sure what's going on yet.
Additional Comment #10 From ac 2009-12-05 18:46
well, in that case I can do an update to 9.10 as a last resort...
Additional Comment #11 From fry 2009-12-05 18:47
oh no, i definitely wouldn't do that! i only meant that as background (i
doubt it has anything to do with that). i assume it works on 8.04 too.
don't install 9.10 on a working system. ;-)
Additional Comment #12 From ac 2009-12-05 18:52
Indeed, upgrading (or doing a fresh install for that matter) would be a
very, very last measure.

My 9.04 system is working quite nicely in fact.

:-)
Additional Comment #13 From ac 2009-12-05 21:12
Ok, I think found something. For any sketch that I try to run in Android
mode, a bunch of files are generated in the corresponding sketch folder in
work/linux/examples. Among them:

AndroidManifest.xml
Build.properties
build.xml
local.properties
...etc

build.xml is the one referencing to com.android.ant.SetupTask:

<?xml version="1.0" encoding="utf-8"?>
<project name="Brightness" default="help">
<property file="local.properties"/>
<property file="build.properties"/>
<property file="default.properties"/>
<path id="android.antlibs">
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
</path>
<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs" />
<setup />
</project>

Now, the variable sdk-location seems to be defined in local.properties,
where it has the (wrong) value:

sdk-location=/opt/android

I modify this value by hand so sdk-location points to the right path, but
when I re-run the sketch, the file gets automatically rewritten with the
wrong value.

What I did next was to create the symbolic link /opt/android pointing to
the correct path for the android-sdk in my system, and then voila!, the
"com.android.ant.SetupTask not found" error went away and the compilation
process proceeded. New error shows up (package processing.android.core does
not exist) but I think the problem seems to be with this wrong path
assignment for the android sdk in /opt. I don't know where is it coming
from, since I set up all the environmental variables to the right location.
Additional Comment #14 From fry 2009-12-06 06:17
ah! good catch. that's why it was working on mine--i always use
/opt/android no matter what platform. the error comes from really early
code that i was using before i had made the sdk location work properly.
that's now fixed in svn, but i need to fix one more issue with the core.zip
file for android before you'll be able to build properly.
Additional Comment #15 From fry 2009-12-06 11:28
this issue is now all set, give 0174 a shot and also w/ the svn. if you run
into new problems use a new bug, since the one here has been fixed.