
lambdaj - issue #93
Impossible to use lambdaj on Android - Runtime error when intstantiating a Predicate
I'm currently building an Android application. As I have to generate statistics and charts from several lists of objects, I was planning on using lambdaj rather than coding complicated loops.
I wrote some code based on lambdaj on a test project. It worked fine, so I decided to integrate it in my android project.
This is a very simple example. I'm creating a predicate to find all GameSets (basically a list of Games) in which a Player is present.
public class PlayerInGameSetPredicate extends Predicate<GameSet> {
private Player player;
public PlayerInGameSetPredicate(final Player player) {
this.player = player;
}
@Override
public boolean apply(final GameSet gameSet) {
return gameSet != null && gameSet.getPlayers().contains(this.player);
}
}
And somewhere I instantiante this class :
... PlayerInGameSetPredicate p = new PlayerInGameSetPredicate(this.player); ...
These two pieces of code compile fine in the Android project. But at runtime, I get a java.lang.NoClassDefFoundError when I try to instantiate the predicate :/ I can't get it to work.
I found a few pages on the internet where people talk of problems that could be caused by the hamcrest library, here for instance : http://stackoverflow.com/questions/5977100/using-lambdaj-in-android
Could you please help with this issue ?
Here is the whole stack, though I doubt it's going to be any help.
04-13 19:56:02.605: E/AndroidRuntime(8291): FATAL EXCEPTION: main 04-13 19:56:02.605: E/AndroidRuntime(8291): java.lang.NoClassDefFoundError: org.nla.tarotdroid.ui.PlayerStatisticsListActivity$PlayerInGameSetPredicate 04-13 19:56:02.605: E/AndroidRuntime(8291): at org.nla.tarotdroid.ui.PlayerStatisticsListActivity.updateGameSetCountView(PlayerStatisticsListActivity.java:237) 04-13 19:56:02.605: E/AndroidRuntime(8291): at org.nla.tarotdroid.ui.PlayerStatisticsListActivity.initializeViews(PlayerStatisticsListActivity.java:160) 04-13 19:56:02.605: E/AndroidRuntime(8291): at org.nla.tarotdroid.ui.PlayerStatisticsListActivity.onCreate(PlayerStatisticsListActivity.java:137) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.os.Handler.dispatchMessage(Handler.java:99) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.os.Looper.loop(Looper.java:130) 04-13 19:56:02.605: E/AndroidRuntime(8291): at android.app.ActivityThread.main(ActivityThread.java:3687) 04-13 19:56:02.605: E/AndroidRuntime(8291): at java.lang.reflect.Method.invokeNative(Native Method) 04-13 19:56:02.605: E/AndroidRuntime(8291): at java.lang.reflect.Method.invoke(Method.java:507) 04-13 19:56:02.605: E/AndroidRuntime(8291): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 04-13 19:56:02.605: E/AndroidRuntime(8291): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 04-13 19:56:02.605: E/AndroidRuntime(8291): at dalvik.system.NativeStart.main(Native Method)
Comment #1
Posted on Apr 22, 2012 by Grumpy RhinoForget about this problem, it was something else entirely... Indeed, I encountered this problem with other libs, among which some I used even before in my project.
The problem is due to a new version of ADT which now requires a /libs source directory in the project to bundle the libraries in the final APK package. This is quite recent (2012), and didn't work like this before. I updated my dev environment, that's what caused the issue.
The actual problem is best described here http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android
Sorry about that mistake.
Comment #2
Posted on Jul 8, 2012 by Helpful Cat(No comment was entered for this change.)
Comment #3
Posted on Aug 15, 2013 by Helpful LionSo is it possible to use Lamdajd on Android or not? :)
Comment #4
Posted on May 8, 2014 by Quick Hippoyes
Comment #5
Posted on Dec 15, 2014 by Swift KangarooDid anyone used it in android ,if so please post it.
Status: Invalid
Labels:
Type-Defect
Priority-Medium