Re: Problem when exporting system packages from Android to bundles

2012-04-03 Thread M. van Ree
Hey Angelo,

For the moment I've only just used BNDTools to generate the manifest which
seems to work well now, the class mismatch error is gone now.
However, I do get a Nullpointer when trying to draw something on the screen
using the imported packages. But I guess that occurs because the bundle
probably can't use the application context just like that by passing it
along.

Thanks for your answers, certainly helped me fix a rather annoying thing,
wish I had used BNDTools earlier on...

Maurice


On Mon, Apr 2, 2012 at 12:04 PM, Angelo van der Sijpt 
angelo.vandersi...@luminis.eu wrote:

 Hi Maurice,

 See inline.

 On Apr 2, 2012, at 11:51 AM, M. van Ree wrote:

  I was considering the use of BNDTools indeed, and will look into that for
  sure now.
  I didn't know about the Bundle-ManifestVersion, will look into that too!
  The comma is indeed a copy-paste error, as you can see in the bottom
 import
  statement, I closed the last one without a comma. But, sharp to notice!

 Well, it's important to have a good view of what actually is going on in
 your code (it could be a simple typo).

 
  As far as tools go, I'm just using Eclipse Indigo and the latest Android
  SDK, dexing and packaging jars with the tools (dx and aapt) from the SDK.
  When opening the bundle jarfile, the API isn't in there, I don't know
 what
  happens after installing and starting the bundle on Felix though...I can
  actually install a bundle and print something to the console or use Log.d
  to show a message in Logcat, so the bundle (without using Android
  libraries) does seem to be packaged in the right way I guess?

 You can use dexdump to inspect the (dalvik-)contents of a bundle.

 
  I'll report back here how things work out after trying BNDTools.

 Good luck!

 
  Maurice

 Angelo

 
  On Mon, Apr 2, 2012 at 11:18 AM, Angelo van der Sijpt 
  angelo.vandersi...@luminis.eu wrote:
 
  Right.
 
  I'm not entirely sure what's up, but some things come to mind,
  - in stead of building the manifest by hand, you should consider using
  something like BND (perhaps with BNDTools, if you're an Eclipse user) to
  handle that for you. If you don't need to use DynamicImport, stick with
  'regular' imports: that way, the framework can inform you better about
  what's wrong.
  - your bundle should have a Bundle-ManifestVersion: 2 to state that it
  is an R4 bundle (again, BND will do that for you).
  - your Import-Package statement seems to have a comma after
  org.osgi.framework . I'm not sure whether that is a copy-paste error, or
  whether it is actually relevant. (insert-bnd-notice/)
  - what tools do you use for building your project? Is it possible that
 the
  Android API ends up _inside_ your bundle?
 
  Angelo
 
  On Apr 2, 2012, at 10:59 AM, M. van Ree wrote:
 
  Hello Angelo,
 
  Thank you for your fast response!
  Here is some more info:
 
  a:
  public FelixManager(String rootPath)
  {
  this.rootPath = rootPath;
  felixProperties = new FelixProperties(this.rootPath);
 
bundlesDir = new File(rootPath+/felix/bundle);
if (!bundlesDir.exists()) {
 if (!bundlesDir.mkdirs()) {
 throw new IllegalStateException(Unable to create bundles dir);
 }
}
cacheDir = new File(rootPath+/felix/cache);
if (!cacheDir.exists()) {
 if (!cacheDir.mkdirs()) {
 throw new IllegalStateException(Unable to create felixcache
  dir);
 }
}
 
try
{
felix = new Felix(felixProperties);
felix.start();
}
catch (Exception ex)
{
ex.printStackTrace();
}
  }
 
  The felix properties are defined as following:
 
  private String m_felixAbsolutePath;
  public FelixProperties(String rootpath)
  {
  m_felixAbsolutePath = rootpath;
  put(org.osgi.framework.storage, m_felixAbsolutePath+/felix/cache);
  put(felix.cache.rootdir,m_felixAbsolutePath+/felix);
  put(felix.log.level, 4);
  put(felix.startlevel.bundle, 1);
  put(org.osgi.framework.system.packages.extra,
  ANDROID_PACKAGES_FOR_EXPORT);
  }
  private final String ANDROID_PACKAGES_FOR_EXPORT=
  android;  +
android.app; +
android.content; +
android.database; + etc. etc.
 
  and b:
 
  Manifest-Version: 1.0
  Bundle-Name: drawbundle
  Bundle-Activator: com.osgi.integration.drawbundle.Activator
  Bundle-SymbolicName: com.osgi.integration.drawbundle
  Bundle-Version: 0.0.1
  Import-Package: org.osgi.framework,
  DynamicImport-Package: android.*
 
  I first, to no avail, tried including the Android packages manually in
  the
  Import-Package statement, like so:
 
  Import-Package: org.osgi.framework,
  android.view.LayoutInflater,
  android.view.View,
  android.widget.LinearLayout,
  android.app.Activity,
  android.app.TextView
 
  I've also tried including the Android jarfile in another bundle, and
  exporting the packages from there, and then importing that bundle in
 the
  above manifest.
 
  Maurice
 
  On Mon

Re: Problem when exporting system packages from Android to bundles

2012-04-03 Thread M. van Ree
 it has to be something with the context passed to the
component name, or the declaration of the intent properties which doesn't
seem to work in OSGi context and does work in a normal Android application.

When I instantiate a new DrawActivity and don't use it, it doesn't show any
errors, it might be a wrong conclusion, but I assume the problem must be in
starting the activity then.
(I tested this to make sure it wasn't a dependency or other bundle/OSGi
related problem)

Maurice


On Tue, Apr 3, 2012 at 1:28 PM, Angelo van der Sijpt 
angelo.vandersi...@luminis.eu wrote:

 Yay, another BNDtools convert! :)

 I'm not sure what you mean by get a Nullpointer when trying to draw
 something on the screen; perhaps you're missing an Acitivity or something.
 Remember that, at least in my experience, the Android lifecycle prevails,
 and OSGi has to be fit into that.

 Angelo


 On Apr 3, 2012, at 11:23 AM, M. van Ree wrote:

  Hey Angelo,
 
  For the moment I've only just used BNDTools to generate the manifest
 which
  seems to work well now, the class mismatch error is gone now.
  However, I do get a Nullpointer when trying to draw something on the
 screen
  using the imported packages. But I guess that occurs because the bundle
  probably can't use the application context just like that by passing it
  along.
 
  Thanks for your answers, certainly helped me fix a rather annoying thing,
  wish I had used BNDTools earlier on...
 
  Maurice
 
 
  On Mon, Apr 2, 2012 at 12:04 PM, Angelo van der Sijpt 
  angelo.vandersi...@luminis.eu wrote:
 
  Hi Maurice,
 
  See inline.
 
  On Apr 2, 2012, at 11:51 AM, M. van Ree wrote:
 
  I was considering the use of BNDTools indeed, and will look into that
 for
  sure now.
  I didn't know about the Bundle-ManifestVersion, will look into that
 too!
  The comma is indeed a copy-paste error, as you can see in the bottom
  import
  statement, I closed the last one without a comma. But, sharp to notice!
 
  Well, it's important to have a good view of what actually is going on in
  your code (it could be a simple typo).
 
 
  As far as tools go, I'm just using Eclipse Indigo and the latest
 Android
  SDK, dexing and packaging jars with the tools (dx and aapt) from the
 SDK.
  When opening the bundle jarfile, the API isn't in there, I don't know
  what
  happens after installing and starting the bundle on Felix though...I
 can
  actually install a bundle and print something to the console or use
 Log.d
  to show a message in Logcat, so the bundle (without using Android
  libraries) does seem to be packaged in the right way I guess?
 
  You can use dexdump to inspect the (dalvik-)contents of a bundle.
 
 
  I'll report back here how things work out after trying BNDTools.
 
  Good luck!
 
 
  Maurice
 
  Angelo
 
 
  On Mon, Apr 2, 2012 at 11:18 AM, Angelo van der Sijpt 
  angelo.vandersi...@luminis.eu wrote:
 
  Right.
 
  I'm not entirely sure what's up, but some things come to mind,
  - in stead of building the manifest by hand, you should consider using
  something like BND (perhaps with BNDTools, if you're an Eclipse user)
 to
  handle that for you. If you don't need to use DynamicImport, stick
 with
  'regular' imports: that way, the framework can inform you better about
  what's wrong.
  - your bundle should have a Bundle-ManifestVersion: 2 to state that
 it
  is an R4 bundle (again, BND will do that for you).
  - your Import-Package statement seems to have a comma after
  org.osgi.framework . I'm not sure whether that is a copy-paste error,
 or
  whether it is actually relevant. (insert-bnd-notice/)
  - what tools do you use for building your project? Is it possible that
  the
  Android API ends up _inside_ your bundle?
 
  Angelo
 
  On Apr 2, 2012, at 10:59 AM, M. van Ree wrote:
 
  Hello Angelo,
 
  Thank you for your fast response!
  Here is some more info:
 
  a:
  public FelixManager(String rootPath)
  {
  this.rootPath = rootPath;
  felixProperties = new FelixProperties(this.rootPath);
 
   bundlesDir = new File(rootPath+/felix/bundle);
   if (!bundlesDir.exists()) {
if (!bundlesDir.mkdirs()) {
throw new IllegalStateException(Unable to create bundles
 dir);
}
   }
   cacheDir = new File(rootPath+/felix/cache);
   if (!cacheDir.exists()) {
if (!cacheDir.mkdirs()) {
throw new IllegalStateException(Unable to create felixcache
  dir);
}
   }
 
   try
   {
   felix = new Felix(felixProperties);
   felix.start();
   }
   catch (Exception ex)
   {
   ex.printStackTrace();
   }
  }
 
  The felix properties are defined as following:
 
  private String m_felixAbsolutePath;
  public FelixProperties(String rootpath)
  {
  m_felixAbsolutePath = rootpath;
  put(org.osgi.framework.storage,
 m_felixAbsolutePath+/felix/cache);
  put(felix.cache.rootdir,m_felixAbsolutePath+/felix);
  put(felix.log.level, 4);
  put(felix.startlevel.bundle, 1);
  put

Re: Problem when exporting system packages from Android to bundles

2012-04-03 Thread M. van Ree
Hi Marcel,

Off course, and I do believe it's an Android/OSGi in general combination
problem (albeit caused by myself), and after all this is the Felix user
list...
Will try some more things and try to narrow down the problem so I can post
a more specific question in the right place!

Maurice

On Tue, Apr 3, 2012 at 7:24 PM, Marcel Offermans 
marcel.offerm...@luminis.nl wrote:

 Hello Maurice,

 I've been following this thread since the start. Could you please try to
 be a bit more specific when asking questions here? We can all see that
 something's not working for you, but you do not provide us with an example
 we can all easily try. That makes it hard to diagnose. Also, like you say,
 you're not even sure if this is a Felix or OSGi related problem, so please
 try to figure that out first and then either post the specific questions in
 the Android forum or here (whatever is more appropriate).

 Greetings, Marcel


 On Apr 3, 2012, at 16:18 , M. van Ree wrote:

  I'm pretty sure it has to be something with the context passed to the
  component name, or the declaration of the intent properties which doesn't
  seem to work in OSGi context and does work in a normal Android
 application.
 
  When I instantiate a new DrawActivity and don't use it, it doesn't show
 any
  errors, it might be a wrong conclusion, but I assume the problem must be
 in
  starting the activity then.
  (I tested this to make sure it wasn't a dependency or other bundle/OSGi
  related problem)


 -
 To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
 For additional commands, e-mail: users-h...@felix.apache.org




-- 
Met vriendelijke groet,

Maurice van Ree


Re: Problem when exporting system packages from Android to bundles

2012-04-02 Thread M. van Ree
Hello Angelo,

Thank you for your fast response!
Here is some more info:

a:
public FelixManager(String rootPath)
{
this.rootPath = rootPath;
felixProperties = new FelixProperties(this.rootPath);

bundlesDir = new File(rootPath+/felix/bundle);
if (!bundlesDir.exists()) {
 if (!bundlesDir.mkdirs()) {
 throw new IllegalStateException(Unable to create bundles dir);
 }
}
cacheDir = new File(rootPath+/felix/cache);
if (!cacheDir.exists()) {
 if (!cacheDir.mkdirs()) {
 throw new IllegalStateException(Unable to create felixcache dir);
 }
}

try
{
felix = new Felix(felixProperties);
felix.start();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}

The felix properties are defined as following:

private String m_felixAbsolutePath;
 public FelixProperties(String rootpath)
{
m_felixAbsolutePath = rootpath;
 put(org.osgi.framework.storage, m_felixAbsolutePath+/felix/cache);
put(felix.cache.rootdir,m_felixAbsolutePath+/felix);
put(felix.log.level, 4);
put(felix.startlevel.bundle, 1);
 put(org.osgi.framework.system.packages.extra,
ANDROID_PACKAGES_FOR_EXPORT);
}
 private final String ANDROID_PACKAGES_FOR_EXPORT=
android;  +
android.app; +
android.content; +
android.database; + etc. etc.

and b:

Manifest-Version: 1.0
Bundle-Name: drawbundle
Bundle-Activator: com.osgi.integration.drawbundle.Activator
Bundle-SymbolicName: com.osgi.integration.drawbundle
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
 DynamicImport-Package: android.*

I first, to no avail, tried including the Android packages manually in the
Import-Package statement, like so:

Import-Package: org.osgi.framework,
 android.view.LayoutInflater,
 android.view.View,
 android.widget.LinearLayout,
 android.app.Activity,
 android.app.TextView

I've also tried including the Android jarfile in another bundle, and
exporting the packages from there, and then importing that bundle in the
above manifest.

Maurice

On Mon, Apr 2, 2012 at 10:39 AM, Angelo van der Sijpt 
angelo.vandersi...@luminis.eu wrote:

 This could have something to do with the way you instantiate your
 framework, _or_ with the way your bundle is packaged.
 Could you post (a) your framework instantiation code, and (b) the manifest
 of your bundle?

 Angelo


 On Apr 2, 2012, at 10:18 AM, M. van Ree wrote:

  Hello all,
 
  I have a problem when trying to make the Android lib available to my OSGi
  bundles.
  The error I'm getting is:
 
  04-02 08:03:00.351: W/dalvikvm(18531): Method mismatch: onDraw in
  Lcom/osgi/integration/drawbundle/DrawView; (cl=0x4067bb40) and super
  Landroid/view/View; (cl=0x0)
  04-02 08:03:00.391: W/System.err(18531): Caused by:
 java.lang.LinkageError:
  Classes resolve differently in superclass
 
  Off course I can see the cl=0x0, so that must be the culprit, but I have
 no
  idea on how to get it fixed...
  I'm exporting the packages as following in a properties class:
 
  private static final String ANDROID_PACKAGES_FOR_EXPORT =
  (android;  +
  android.app; +
  android.content; +
  android.database; +
  etc. etc. );
 
  I'm really drawing a blank here on what could be wrong, I would expect to
  receive an error on exporting/importing something empty that would point
 me
  in the right direction, but it doesn't seem to be the case.
  Who can tell me what I'm doing wrong here?
 
 
  Regards,
  Maurice



 -
 To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
 For additional commands, e-mail: users-h...@felix.apache.org




-- 
Met vriendelijke groet,

Maurice van Ree


Re: Problem when exporting system packages from Android to bundles

2012-04-02 Thread M. van Ree
I was considering the use of BNDTools indeed, and will look into that for
sure now.
I didn't know about the Bundle-ManifestVersion, will look into that too!
The comma is indeed a copy-paste error, as you can see in the bottom import
statement, I closed the last one without a comma. But, sharp to notice!

As far as tools go, I'm just using Eclipse Indigo and the latest Android
SDK, dexing and packaging jars with the tools (dx and aapt) from the SDK.
When opening the bundle jarfile, the API isn't in there, I don't know what
happens after installing and starting the bundle on Felix though...I can
actually install a bundle and print something to the console or use Log.d
to show a message in Logcat, so the bundle (without using Android
libraries) does seem to be packaged in the right way I guess?

I'll report back here how things work out after trying BNDTools.

Maurice

On Mon, Apr 2, 2012 at 11:18 AM, Angelo van der Sijpt 
angelo.vandersi...@luminis.eu wrote:

 Right.

 I'm not entirely sure what's up, but some things come to mind,
 - in stead of building the manifest by hand, you should consider using
 something like BND (perhaps with BNDTools, if you're an Eclipse user) to
 handle that for you. If you don't need to use DynamicImport, stick with
 'regular' imports: that way, the framework can inform you better about
 what's wrong.
 - your bundle should have a Bundle-ManifestVersion: 2 to state that it
 is an R4 bundle (again, BND will do that for you).
 - your Import-Package statement seems to have a comma after
 org.osgi.framework . I'm not sure whether that is a copy-paste error, or
 whether it is actually relevant. (insert-bnd-notice/)
 - what tools do you use for building your project? Is it possible that the
 Android API ends up _inside_ your bundle?

 Angelo

 On Apr 2, 2012, at 10:59 AM, M. van Ree wrote:

  Hello Angelo,
 
  Thank you for your fast response!
  Here is some more info:
 
  a:
  public FelixManager(String rootPath)
  {
  this.rootPath = rootPath;
  felixProperties = new FelixProperties(this.rootPath);
 
 bundlesDir = new File(rootPath+/felix/bundle);
 if (!bundlesDir.exists()) {
  if (!bundlesDir.mkdirs()) {
  throw new IllegalStateException(Unable to create bundles dir);
  }
 }
 cacheDir = new File(rootPath+/felix/cache);
 if (!cacheDir.exists()) {
  if (!cacheDir.mkdirs()) {
  throw new IllegalStateException(Unable to create felixcache
 dir);
  }
 }
 
 try
 {
 felix = new Felix(felixProperties);
 felix.start();
 }
 catch (Exception ex)
 {
 ex.printStackTrace();
 }
  }
 
  The felix properties are defined as following:
 
  private String m_felixAbsolutePath;
  public FelixProperties(String rootpath)
  {
  m_felixAbsolutePath = rootpath;
  put(org.osgi.framework.storage, m_felixAbsolutePath+/felix/cache);
  put(felix.cache.rootdir,m_felixAbsolutePath+/felix);
  put(felix.log.level, 4);
  put(felix.startlevel.bundle, 1);
  put(org.osgi.framework.system.packages.extra,
  ANDROID_PACKAGES_FOR_EXPORT);
  }
  private final String ANDROID_PACKAGES_FOR_EXPORT=
  android;  +
 android.app; +
 android.content; +
 android.database; + etc. etc.
 
  and b:
 
  Manifest-Version: 1.0
  Bundle-Name: drawbundle
  Bundle-Activator: com.osgi.integration.drawbundle.Activator
  Bundle-SymbolicName: com.osgi.integration.drawbundle
  Bundle-Version: 0.0.1
  Import-Package: org.osgi.framework,
  DynamicImport-Package: android.*
 
  I first, to no avail, tried including the Android packages manually in
 the
  Import-Package statement, like so:
 
  Import-Package: org.osgi.framework,
  android.view.LayoutInflater,
  android.view.View,
  android.widget.LinearLayout,
  android.app.Activity,
  android.app.TextView
 
  I've also tried including the Android jarfile in another bundle, and
  exporting the packages from there, and then importing that bundle in the
  above manifest.
 
  Maurice
 
  On Mon, Apr 2, 2012 at 10:39 AM, Angelo van der Sijpt 
  angelo.vandersi...@luminis.eu wrote:
 
  This could have something to do with the way you instantiate your
  framework, _or_ with the way your bundle is packaged.
  Could you post (a) your framework instantiation code, and (b) the
 manifest
  of your bundle?
 
  Angelo
 
 
  On Apr 2, 2012, at 10:18 AM, M. van Ree wrote:
 
  Hello all,
 
  I have a problem when trying to make the Android lib available to my
 OSGi
  bundles.
  The error I'm getting is:
 
  04-02 08:03:00.351: W/dalvikvm(18531): Method mismatch: onDraw in
  Lcom/osgi/integration/drawbundle/DrawView; (cl=0x4067bb40) and super
  Landroid/view/View; (cl=0x0)
  04-02 08:03:00.391: W/System.err(18531): Caused by:
  java.lang.LinkageError:
  Classes resolve differently in superclass
 
  Off course I can see the cl=0x0, so that must be the culprit, but I
 have
  no
  idea on how to get it fixed