zhiqinghuang / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Impossible to use lambdaj on Android - Runtime error when intstantiating a Predicate #93

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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(Player
StatisticsListActivity.java:237)
04-13 19:56:02.605: E/AndroidRuntime(8291):     at 
org.nla.tarotdroid.ui.PlayerStatisticsListActivity.initializeViews(PlayerStatist
icsListActivity.java:160)
04-13 19:56:02.605: E/AndroidRuntime(8291):     at 
org.nla.tarotdroid.ui.PlayerStatisticsListActivity.onCreate(PlayerStatisticsList
Activity.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)

Original issue reported on code.google.com by laurent....@gmail.com on 13 Apr 2012 at 8:10

GoogleCodeExporter commented 8 years ago
Forget 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-andr
oid

Sorry about that mistake.

Original comment by laurent....@gmail.com on 22 Apr 2012 at 7:43

GoogleCodeExporter commented 8 years ago

Original comment by mario.fu...@gmail.com on 8 Jul 2012 at 10:58

GoogleCodeExporter commented 8 years ago
So is it possible to use Lamdajd on Android or not? :)

Original comment by kosiara87 on 15 Aug 2013 at 4:16

GoogleCodeExporter commented 8 years ago
yes

Original comment by animaonl...@gmail.com on 8 May 2014 at 1:30

GoogleCodeExporter commented 8 years ago
Did anyone used it in android ,if so please post it.

Original comment by sangames...@gmail.com on 15 Dec 2014 at 9:18