Giter Site home page Giter Site logo

Comments (14)

czyzby avatar czyzby commented on May 20, 2024 1

You made a typo. It's czyzby, not czyzboy. This is likely what causes the issue. Packages have to match exactly.

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

I don't actively develop my LibGDX utilities lately, but I'll look into before the next release. If this issue blocks you, your best bet is to fork the library and add the method yourself - it's a very simple getter. There's no reason for reflection to fail to fetch the field value either, can you show me the code?

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

thank you for your quick answer !
Unfortunately I'm not a very good Java Programmer so I don't usually do reflexion all the day.
If you want this is a piece of my code of core :

`

                    socket = ExtendedNet.getNet().newWebSocket(Constants.SERVER_HOST_IP, 2712);
		
		nethandler = new NetworkHandler(l7s,socket);	
		socket.addListener(nethandler);
		l7s.setNethandler(nethandler);
		
		try
		{
			
			socket.connect();
                      



		}
		catch(WebSocketException e)
		{
			e.printStackTrace();
			
		}`

but I found in AndroidLauncher.java, when I call CommonWebSocket.iniate(); it return a new nvWebSocket by a factory, and there I tryed the reflexion but has I don' tknow exactly what to do i'm a bit lost.. I can indeed get the source code and modify by my own but I try to understand exactly how your lib work, I mean how exactly you do the bridge between nvWebSocket and platform WS Implementation

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

This is the line where a new web socket is created - you probably want to add your extra settings there.

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

ok thank you, So i just need to clone this github repo as usual and import it as a classic java project, is that right ?

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

You could do that, but you'll find it easier to create a Java file with the same package and name in your project to patch the library. I remember doing it for some LibGDX classes back when I was starting as well - the compiler/build tool seems to prefer files from your project over the third-party libraries, so as long as you keep the same name and do not modify the publicly used interface, you should be fine.

  • Add com.github.czyzby.websocket.impl package in your source folder.
  • Create NvWebSocket.java file.
  • Copy the source.
  • Apply your changes.

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

Ok thank you again and again for your help and patience;

I've create package as you described in my android project, added a the new java class into it but I got an error on Line 27 on NvWebSocketLister(this) and when I import it ( import com.github.czyzby.websocket.impl.NvWebSocketListener;) it say that the constructor doesnt accept this type of object :

image

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

By the way, you should try using IntelliJ/Android Studio instead of Eclipse - especially if you plan on releasing a mobile version.

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

YEA ! thank you the error disappear !!
Yes i'm using android studio when I want to test on my device the game and deploy a signed apk but I prefer eclipse so I code my core game with eclipse and use android studio only when I debug android and Packaging apk.
Thank you again for your support !

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

ok this work on desktop.
However on android, it fail on gradle build here the error :

Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/github/czyzby/websocket/impl/NvWebSocket$1; Message{kind=ERROR, text=Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/github/czyzby/websocket/impl/NvWebSocket$1;, sources=[Unknown source file], original message=UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/github/czyzby/websocket/impl/NvWebSocket$1; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) , tool name=Optional.of(Dex)}

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

That's because both you and gdx-websockets define the same class. I'm pretty sure there's a way to work around this, but I'm afraid Googling com.android.dex.DexException: Multiple dex files define is your best bet for possible solutions.

The alternative is to clone this repo, modify the library source and publish the lib to your Maven Local with gradle build install. Not sure what would require more time to resolve this issue, but you'll have to do some digging on how Gradle/Maven works before getting this right. :)

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

ok czyzby thank you, I will try this today !

from gdx-lml.

ange-black69 avatar ange-black69 commented on May 20, 2024

Hello,
I come back with some news.
I think I understand way better how gradle work with maven integration etc..

If i understand correctly, my best bet is to clone this repo, made my change, build the new project into a jar file and then in the build.gradle file compile fileTree(dir: 'libs', include: '*.jar').

I read this usefull article : https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle#mavenizing-local-dependencies
But now i'm a little confused.
I understand that I can publish the lib to my local maven repo, and then from build.gradle script, I can retrieve it localy. ( compile "::"
compile ":::sources" etc..)

So what is the best solution ?

from gdx-lml.

czyzby avatar czyzby commented on May 20, 2024

When you clone the repository, you can execute gradle build install to push all libraries to your Maven local. You can also change the version of the dependencies here. Replace libVersion with your custom value and you can import the library in your project as any other artifact.

Make sure to add mavenLocal() to your repositories and then you can just add your custom modified library with:

compile "com.github.czyzby:gdx-websocket-common:1.2.3-YOUR_VERSION"

from gdx-lml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.