I had some similar issues to you trying to get a library working with an Android JUCE project.
Everything in the libs folder gets deleted/overwritten each time you run a build. This is the way ant works.
Have you looked at the Android.mk file? This is where ant (or eclipse I assume) pulls everything together.
Jules recently added an option to Introjucer to add external libraries, but it is not currently complete. I've sent a patch for this which should work on the latest tip. (See below, could not upload the file..)
If you apply the patch to JUCE, then when you open the project in Introjucer you should be able to declare the location of static (.a) or shared (.so) libraries there, and it will add the necessary lines to JUCE's Android.mk. You will also need to create a separate build for your library with its own Android.mk file, and set its location in NDK_MODULE_PATH.
I've given a working example for the Aubio library here: https://github.com/adamski/aubio-android
To understand the mechanics of all of this have a read around here: http://www.kandroid.org/ndk/docs/IMPORT-MODULE.html
You can of course declare everything in JUCE's Android.mk file but then you will need to manage it in your VCS, as it will get overwritten each time Introjucer saves the project. I made an earlier modification to Introjucer where it added everything into the one file but it got complicated to generalise it for different use cases. Separating the library build from JUCE simplifies things.
Good luck and feel free to post more details here.
Patch:
diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h
index 3c99132..1f30928 100644
--- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h
+++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h
@@ -100,8 +100,11 @@ public:
props.add (new TextPropertyComponent (getOtherPermissionsValue(), "Custom permissions", 2048, false),
"A space-separated list of other permission flags that should be added to the manifest.");
- props.add (new TextPropertyComponent (getImportModulesValue(), "Import modules", 8192, true),
- "Comma or whitespace delimited list of import-module calls.");
+ props.add (new TextPropertyComponent (getStaticLibrariesValue(), "Import static library modules", 8192, true),
+ "Comma or whitespace delimited list of static libraries (.a) defined in NDK_MODULE_PATH.");
+
+ props.add (new TextPropertyComponent (getSharedLibrariesValue(), "Import shared library modules", 8192, true),
+ "Comma or whitespace delimited list of static libraries (.so) defined in NDK_MODULE_PATH.");
props.add (new TextPropertyComponent (getThemeValue(), "Android Theme", 256, false),
"E.g. @android:style/Theme.NoTitleBar or leave blank for default");
@@ -146,9 +149,12 @@ public:
Value getThemeValue() { return getSetting (Ids::androidTheme); }
String getThemeString() const { return settings [Ids::androidTheme]; }
- Value getImportModulesValue() { return getSetting (Ids::androidImportModules); }
- String getImportModulesString() const { return settings [Ids::androidImportModules]; }
+ Value getStaticLibrariesValue() { return getSetting (Ids::androidStaticLibraries); }
+ String getStaticLibrariesString() const { return settings [Ids::androidStaticLibraries]; }
+ Value getSharedLibrariesValue() { return getSetting (Ids::androidSharedLibraries); }
+ String getSharedLibrariesString() const { return settings [Ids::androidSharedLibraries]; }
+
Value getCPP11EnabledValue() { return getSetting (Ids::androidCpp11); }
bool isCPP11Enabled() const { return settings [Ids::androidCpp11]; }
@@ -478,6 +484,19 @@ private:
out << " " << (files.getReference(i).isAbsolute() ? "" : "../")
<< escapeSpaces (files.getReference(i).toUnixStyle()) << "\\" << newLine;
+ const StringArray staticLibraries (getCommaOrWhitespaceSeparatedItems (getStaticLibrariesString()));
+ const StringArray sharedLibraries (getCommaOrWhitespaceSeparatedItems (getSharedLibrariesString()));
+
+ if (staticLibraries.size() > 0) out << newLine << "LOCAL_STATIC_LIBRARIES :=";
+ for (int i = 0; i < staticLibraries.size(); ++i)
+ out << " " << staticLibraries[i];
+ if (staticLibraries.size() > 0) out << newLine;
+
+ if (sharedLibraries.size() > 0) out << newLine << "LOCAL_SHARED_LIBRARIES :=";
+ for (int i = 0; i < sharedLibraries.size(); ++i)
+ out << " " << sharedLibraries[i];
+ if (sharedLibraries.size() > 0) out << newLine;
+
out << newLine
<< "ifeq ($(NDK_DEBUG),1)" << newLine;
writeConfigSettings (out, true);
@@ -487,11 +506,13 @@ private:
<< newLine
<< "include $(BUILD_SHARED_LIBRARY)" << newLine;
- const StringArray importModules (getCommaOrWhitespaceSeparatedItems (getImportModulesString()));
- for (int i = 0; i < importModules.size(); ++i)
- out << "$(call import-module," << importModules[i] << ")" << newLine;
- }
+ for (int i = 0; i < staticLibraries.size(); ++i)
+ out << "$(call import-module," << staticLibraries[i] << ")" << newLine;
+
+ for (int i = 0; i < sharedLibraries.size(); ++i)
+ out << "$(call import-module," << sharedLibraries[i] << ")" << newLine;
+ }
void writeConfigSettings (OutputStream& out, bool forDebug) const
{
diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h
index 7e1b952..69f1527 100644
--- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h
+++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h
@@ -142,7 +142,8 @@ namespace Ids
DECLARE_ID (androidKeyAlias);
DECLARE_ID (androidKeyAliasPass);
DECLARE_ID (androidTheme);
- DECLARE_ID (androidImportModules);
+ DECLARE_ID (androidStaticLibraries);
+ DECLARE_ID (androidSharedLibraries);
DECLARE_ID (font);
DECLARE_ID (colour);
DECLARE_ID (userNotes);