2

I link a library project in my project.properties File of the library-consuming project

android.library.reference.1=~/Documents/Workspace/LibraryProject/

the project.properties of the library project says:

android.library=true

I read on here that I have to use relative paths. So I use the path with the tilde on the front since I read this is considered a relative path on Unix based OS, which I use (Mac OS).

however when I build my project with an Ant script (I dont post it here because it works without that line above, so I think it´s not the problem), I get the following error:

/Users/home/Documents/android-sdk-macosx/tools/ant/build.xml:545: ~/Documents/Workspace/LibraryProject/ resolve to a path with no project.properties file for project /Users/home/ApplicationAndroidBuilt

EDIT

After I updated my code to Boris Answer I get another Error, but I think I´m on the right way

here is what I do in the ant script now

<target name="updateProject">

    <echo>updating Project...</echo>
    <!-- The Library -->
    <exec dir="${android_home}/tools" executable="./android">
        <arg line="update"/>
        <arg line="project"/>
        <arg line="--target"/>
        <arg line="4"/>
        <arg line="-p"/>
        <arg line="${scannerLibrary_home}"/>
    </exec>
   <!-- The consuming Project -->
    <exec dir="${android_home}/tools"  executable="./android"> 
        <arg line="update"/>
        <arg line="project"/>
        <arg line="--target"/>
        <arg line="4"/>
        <arg line="-p"/>
        <arg line="${targetdir}"/>
    </exec>

    <antcall target="buildScanner"/>
</target>

<target name="buildScanner">
    <exec dir="${scannerLibrary_home}"  executable="ant"> 
        <arg line="clean"/>
        <arg line="release"/>
    </exec>
    <antcall target="buildProject"/>
</target>

<target name="buildProject">
    <exec dir="${targetdir}"  executable="ant"> 
        <arg line="debug"/>
    </exec>
    <antcall target="install"/>
</target>

I get this error now:

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

Googling a bit, it says I have to provide the path to my android_home in the local.properties file in the library project, which I do:

sdk.dir=/Users/home/Documents/android-sdk-macosx

sadly no luck yet, anyone knows what`s the trouble here?

EDIT 2:

After deleting the build.xml file of the Library-consuming Project, the error with the SetupTask not found disappeared, but the "resolve to a path with no project.properties" from my original post shows up again. Even tho the path is correct and points to a directory with a project.property file.

Community
  • 1
  • 1
最白目
  • 3,505
  • 6
  • 59
  • 114

2 Answers2

0

You need to run ant project update --path . first in the folder of the library and then in the folder of the project.

Just then you are set up for compilation. You need to separately build first the library with, say, ant clean release and just then ant clean release in the project using the library.

Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135
  • I updated the project. The new error in the headline now is fixed now too, but I get the first error again. So I started a new question http://stackoverflow.com/questions/12086154/android-ant-error-resolve-to-a-path-with-no-project-properties-file-for-project – 最白目 Aug 23 '12 at 06:48
  • @dan The path tot he android sdk should be automatically added after you run `andriod update project --path .` – Boris Strandjev Aug 23 '12 at 06:56
  • yes you´re right, the path was added automatically. Sadly it doesnt fix my problem. – 最白目 Aug 23 '12 at 06:59
  • @dan for me the erro you are getting is pretty obvious: you call ant task `SetupTask`, which you never define. Maybe post the whole ant file you have (or at least the portions of the autogenerated file you edited). – Boris Strandjev Aug 23 '12 at 07:08
  • 1
    But I´m not getting this SetupTask error anymore, I had to delete the Build-File of the Consuming Project and run android update project again. I now get the first error "resolve to a path with no project.properties file for project.." again. I appreciate your help! – 最白目 Aug 23 '12 at 07:12
  • @dan Then just create project properties file with these two lines: `target=android-8 android.library=true ` – Boris Strandjev Aug 23 '12 at 07:27
  • I have the file. Exactly with the 2 lines – 最白目 Aug 23 '12 at 08:02
  • @dan where do you have the file. I mean is it in the library, the project or both? – Boris Strandjev Aug 23 '12 at 08:11
  • I have it in both, in the Library it says what you wrote (target and library=true), in the Project it contains the line android.library.reference.1=~/Documents/Workspace/LibraryProject/ – 最白目 Aug 23 '12 at 08:44
  • @dan I am a bit confused now. Can you say once more what your current state is and what error you get – Boris Strandjev Aug 23 '12 at 11:13
  • @dan you say you deleted the build.xml, but did you recreated it afterwards? – Boris Strandjev Aug 23 '12 at 12:26
  • no, it was recreated automatically after running ./android project update – 最白目 Aug 23 '12 at 12:42
  • Maybe try replacing `~/Documents/Workspace/LibraryProject/` with `../LibraryProject/` – Boris Strandjev Aug 23 '12 at 12:49
  • @dan actually the suggested path by me is incorrect, but can you verify please that the path to the library is ok – Boris Strandjev Aug 23 '12 at 13:32
  • yes, I can ensure that. Doing a cd cd ~/Documents/Workspace/LibraryProject/ and then a ls -l it shows the contents of the Library inculding the project.properties. – 最白目 Aug 23 '12 at 13:43
  • @dan keep in mind that the way paths are defined for ant is not neccessarily the same it is defined for ant. This is why I suggested opting out of ~ and using `../`, but I think I got the relative path wrongly. – Boris Strandjev Aug 23 '12 at 14:22
  • yes I found out about that. I tried so many things now. Is it because I copy one project into a new project? I update/reference the library in both the source and the target folder. I just dont know whats wrong I keep getting this error. – 最白目 Aug 24 '12 at 05:46
  • @dan I am out of the ideas currently, i will reflect upon it for some time now. – Boris Strandjev Aug 24 '12 at 07:10
0

In reference to the "resolve to a path with no project.properties" -- Just in case someone else hits it: I had an extra space on the end of my "android.library.reference.1=abc " line which caused my headache. Once I removed the extra space, everything worked.

DustinB
  • 11,037
  • 5
  • 46
  • 54