I'm trying to convince an embedded Apache Felix on Android to start an external bundle.
So far I have managed to embed the felix.jar into its own APK and run it as an activity. Within this activity I'm able to install outside bundles from jar files. Unfortunately whenever I try to move on and start one of these bundles I get the following error:
Encountered exception when starting bundle:
Unresolved constraint in bundle com.example.hellofelix [1]:
Unable to resolve 1.0:
missing requirement [1.0] osgi.ee;
(&(osgi.ee=JavaSE)(version=1.7.0))
As com.example.hellofelix
is the package name for my test application this suggests that my app is missing the osgi.ee package required by the constraint of JavaSE 1.7.0.
How exactly do I solve this problem?
Do I have to specify en extra export in my app, import something or just add another bundle?
My bundle's code:
Activator:
package com.example.dictionary;
import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import com.example.dictionary.service.DictionaryBundle;
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("Language", "de-en");
context.registerService(DictionaryBundle.class.getName(), new DictionaryBundleImpl(), props);
}
public void stop(BundleContext context) throws Exception {
// NOTE: The service is automatically unregistered.
}
}
Interface:
package com.example.dictionary.service;
public interface DictionaryBundle {
public String translate(String wordToTranslate);
}
Implementation:
package com.example.dictionary;
import java.util.Hashtable;
import com.example.dictionary.service.DictionaryBundle;
public class DictionaryBundleImpl implements DictionaryBundle {
private Hashtable<String, String> dictionary;
public DictionaryBundleImpl() {
dictionary = new Hashtable<>();
dictionary.put("ente", "duck");
dictionary.put("hund", "dog");
dictionary.put("kuh", "cow");
dictionary.put("katze", "cat");
dictionary.put("maus", "mouse");
}
public String translate(String wordToTranslate) {
return dictionary.get(wordToTranslate);
}
}
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-SymbolicName: com.example.hellofelix
Export-Package: com.example.dictionary.service
Bundle-Name: TestBundle
Bundle-Version: 1.4.2.qualifier
Bundle-ManifestVersion: 2
Bundle-Activator: com.example.dictionary.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-Vendor: None
Thank you very much!