ejoftheweb
|
Posted: September 23, 2009 08:02 by ejoftheweb
|
|
Just getting started with the plugin so I can begin to deploy some of my code and test it on my new T-Mobile G2 (HTC Hero) which is arriving this morning. Hallo World running well on the emulator. plugin is pretty cool, good work! I've run into a little hiccough with libraries, and I don't know yet whether it's a bug or a feature, because I'm still not fully familiar with the whole apk architecture and deployment strategy. Is there a way I can deploy shared libraries to Android, or do I have to package my shared libraries separately with each app? I find I can't add a library to the Android project in NB. Well, I can, but only through right-clicking the libraries node in the project view. The Libraries node in the project properties dialog doesn't work. Right-clicking the libraries node in the project view, I can only add a Library, not a project. I like to keep as much generic code as I can in separate library projects to make it easier to reuse it, so I'd really like to be able to add library projects to my Android projects. |
Libraries..
Replies: 6 - Last Post: February 09, 2011 03:45
by: Jeff
by: Jeff
showing 1 - 7 of 7
edru
|
Posted: October 03, 2009 02:36 by edru
|
|
I also had problems using 3rd party libraries. My solution was to modify the -dex target in build-impl.xml to match the one created by the android command line project builder. My ant target now looks like this: <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-dex"> <apply executable="${dx}" failonerror="true" parallel="true" > <arg value="--dex"/> <arg value="--output=${basedir}/${intermediate.dex}"/> <arg value="--positions=lines"/> <arg path="${build.classes.dir}"/> <fileset dir="${basedir}/${external-libs}" includes="*.jar"/> </apply> </target> The exec was changed to apply (be sure to add the parallel="true") and I added the fileset which includes any jars in the libs directory. I also defined external-libs in project.properies as follows: external-libs=libs These minor changes make it so any jar files are added to the final android package. If someone knows of a better way to do this then please post here. |
derlangeron
|
Posted: October 02, 2010 22:34 by derlangeron
|
Simply add following code at the end of the project tag in build.xml:
<target name="-pre-jar">
<property name="external.libs.dir" value="${basedir}/lib" />
<copy todir="${build.classes.dir}">
<fileset dir="${basedir}/lib" />
</copy>
</target>
where the 3rd party libraries placed in a folder called 'lib' in your project folder. Then you can add new libraries via add library/add jar in Netbeans, _if_ they are placed in the lib folder they will be deployed, too
|
turnerjos
|
Posted: October 07, 2009 17:46 by turnerjos
|
|
A giant "me too" on this issue. I regularly build a POJO-based domain model for applications, then import the project into the both the client and server implementations. Combined with a good POJO serialization library, this approach makes shovelling objects back and forth between client and server really easy. Unfortunately, until nbandroid can import libraries (or projects), all I can build are monolithic applications, which really limits the usefulness of the plugin. |
Mark McKay
|
Posted: October 13, 2009 10:51 by Mark McKay
|
|
Me three. I'm new to this Android platform and just got my Hello World working. I'd like to port a POJO library that I have which builds and runs for J2SE. I read on another forum that J2SE byte code != Android byte code, and was wondering - how I would even go about compiling the jar that I would need for a library? The Android task doesn't seem to output jar files. Or will the Android compiler translate a J2SE jar on the fly? |
Jeff
|
Posted: February 08, 2011 05:22 by Jeff
|
|
For anybody's who's interested, here's how I was able to not only add a thirdparty jarfile (Droid-Fu), but reference its source & javadocs so code-completion and inline Javadocs work as well. I'm using Netbeans 6.8. I haven't tested other versions. I'm using NBandroid built from source I grabbed sometime around New Year's Eve. I don't know whether this will work with v0.10, I'm pretty sure it will work with 0.12 once it's released. I'm running Windows 7, set the build target to API3, 1.5 + Google, and successfully ran it on the emulator with API7, 2.1 + Google. I'm pretty sure Netbeans is using 1.6.0_22-b04 as the jdk. 1. added the following to build.xml, right before the closing project tag:
<target name="-pre-jar">
<property name="external.libs.dir" value="${basedir}/lib" />
<copy todir="${build.classes.dir}">
<fileset dir="${basedir}/lib" />
</copy>
</target>2. Created a directory named lib in my project's rootdir (in my case, c:\repo\projects\ap1\lib) 3. Created a symlink to the jarfile (if anyone needs a reason to upgrade to Vista or Win7, that's the big one... real symlinks at last!). In my case, I cd'ed to the project's lib directory, and did mklink droid-fu-1.0-SNAPSHOT.jar \repo\droid-fu\target\droid-fu-1.0-SNAPSHOT.jar 4. Exited and restarted Netbeans. If everything went well, there will now be a "Libraries" node for the project. If all the nodes have disappeared, try exiting and reloading Netbeans again. 5. Right-click Libraries, select "Add Library". As far as I can tell, "Add Project" doesn't work (yet). 6. Add a new Library. I did it for an awesome thirdparty library called Droid-Fu. In my case, I actually have Droid-Fu itself as a Maven-based Netbeans project. To begin, click "Manage Libraries" 7. Classpath tab, click add Jar/folder and select droid-fu-1.0-SNAPSHOT.jar (in my case, it was c:\repo\droid-fu\target\droid-fu-1.0-SNAPSHOT.jar). Yes, I did this in addition to symlinking the jarfile. More on this at the end. 8. Sources tab, clicked Add JAR/Folder and selected c:\repo\droid-fu\src\main. For anybody who's wondering, 'main' contains the 'java' folder, and the 'java' folder contained 'com' (the top-level source folder for com.github.droidfu). If you try setting the 'sources' folder to c:\repo\droid-fu\src\main\java, it won't work (or at least it didn't work when I tried it). 9. Javadoc tab, clicked Add ZIP/folder and selected c:\repo\droid-fu\target\site\apidocs. 'com' and 'index.html' (plus the rest) were all in the apidocs subdirectory. I don't remember whether I had to exit and restart Netbeans to get the paths re-scanned. I just know that right now, I appear to have the thirdparty library successfully added, with full inline ctrl-space javadocs and code completion. The only thing that doesn't appear to be working is displaying methods not inherited from a superclass displayed in bold... and for all I know, that might just be due to the current state of Droid-Fu's Javadocs. For anybody who didn't quite notice it, I symlinked the jarfile to the lib directory AND referenced it from within the Netbeans library. I'm pretty sure that this is going to break in the near future and become unnecessary. For now, though, it appears that you need to have the physical jarfile (or a symlink to it) present in the /lib directory for build.xml to copy at build time in order for it to actually WORK, but you need to ALSO define it as a Netbeans library and add the library to the project in order to make code-completion and inline javadocs work. If double-referencing the jarfile becomes unnecessary at some point, but having SOMETHING in the lib directory is needed for the rest of it to work, just create a file in lib called readme.txt (or something similar). |
Jeff
|
Posted: February 09, 2011 03:45 by Jeff
|
|
Update. While reading over the repo commit log, I noticed that v0.11 came out in early December (somehow, I got so caught up with getting it to build from source back in December that I managed to completely overlook 0.11's release), and it also looks like Radim is now using 6.9. So... I decided to try installing 6.9 and 0.11 to see whether what I did last night would still work. Code-completion and inline javadocs: worked. Build with thirdparty jarfile: died, but I think it was for an unrelated reason. The actual error was: java.io.IOException: Cannot run program "${platforms.7android2.1.aapt}" (in directory "C:\repo\projects\nbe"): CreateProcess error=2, The system cannot find the file specified I'm not sure whether that's a "6.9.1 isn't quite supported yet" error, a "0.11 is missing something that nbm files built from source updated over the past 6 weeks added or fixed" error, both, or neither. I think I'm going to try building a new copy of the .nbm files from the latest source in the repo and try it with 6.9.1 later tonight. For now, I'm leaving 6.8 alone, because it seems to be working and I want to keep it that way ![]() *Update 2* No dice. 6.9.1 still seems to be missing aapt, even after grabbing the latest nbAndroid source & building it. So, it looks like it's back to 6.8 for now. |
showing 1 - 7 of 7
Replies: 6 - Last Post: February 09, 2011 03:45
by: Jeff
by: Jeff






