can I customize my existing LibGDX project with the gds-setup.jar? - java

I've created my game with Lib-GDX and I'm almost done! :D
the problem is that I forgot to include one of the Third Party feature in the initial GDX setup. Is there any way I can go back and include it, using the gds-setup.jar or any other way? Or must I go the super advanced way and create a new project and include the feature?
To be more precise I'm trying to include the libGDX cross platform Facebook support

You can just add your 3d party stuff to the build.gradle file for your case your need this :
compile "de.tomgrill.gdxfacebook:gdx-facebook-core:1.1.1"
to be added to the dependencies, there is no need of creating new project with gdx-setup.jar
check this topic in the officiel wiki for more info :
Dependency management with Gradle

I just created a new project with gdx-setup.jar and added the Third Party Ext. I wanted. Once that was complete i copied the code that called the TPE in the gradle files and added them to my original game's gradle so for Example:
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "de.tomgrill.gdxfacebook:gdx-facebook-android:1.1.1"//this is what I needed to add
compile fileTree(dir: 'libs', include: '*.jar')
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "de.tomgrill.gdxfacebook:gdx-facebook-core:1.1.1"//this was what I needed to add
compile fileTree(dir: 'libs', include: '*.jar')
}
}
this was all in the main project's gradle folder.

Related

Put custom jar into jar

Background:
A part of Microservices is that you end up building some utility libraries that are needed by your services. Now I've needed to create a library that's used by my libraries.
Problem:
So I need a jar file (we're going to call jar-a) that I'm building with gradle to include another one of my jar files (which we'll call jar-b).
I have set up my configuration for jar-a build thus:
repositories {
...
flatDir {
dirs 'libs'
}
}
dependencies {
...
compile fileTree(dir: 'libs', include: ['*.jar'])
...
}
This works great for the build, but for deployment, I want my copy of the jar-b included in jar-a.
I've tried googling this and found some things that I can't link to the documentation to understand, so I can't break it down to use it.

include gturri android xml rpc library in android project

i need to include this library but i ve got several problems.
project library on github
i tried to follow the instructions on the github project but they did not work for me. I have to include the library in android studio.
i tried to:
1) copy the whole code in my project but i had a lot of conflicts about package, and, once solved, i began to have problems about lacks of functions not defined
2) i tried to use mvn install command, but it did not work, something like 100 errors displayed
3) i tried to open that project with intelliJ and then i tried to export jar file, but intelliJ told that it s an android project
does anyone have any idea about the procedure to include this library?
Thanks a lot in advance
you could give Jitpack a try. At least it worked for me..
See https://jitpack.io/
In essence: add following code to the build.gradle file of your project:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and add the following line to the dependencies section in the build.gradle file of your app:
`compile 'com.github.gturri:aXMLRPC:master-SNAPSHOT'`
here is what the dependency section looks like for me:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.gturri:aXMLRPC:master-SNAPSHOT'
compile 'com.android.support:support-v4:23.4.0'
}

How do I include another project's class libraries in my jar using Gradle?

I am developing for Android, and I am trying to include another project's class files in my .jar file.
My build.gradle file for library project looks like this:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
compile project(':xyz')
}
My build.gradle file for xyz project looks like this:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
The issue is that when I create another project that includes my jar library, it has unresolved references that exist in my xyz project. When I run that project, it complains about not being able to find a class that exists in the xyz project.
Right click on app , open module settings (F4), Dependencies, Green + and select library file. build.gradle is updated automatically :)

Cannot resolve symbol in Android

I am working on integrating twitter with my android application, I am using twitter4j library to do this.
I have added the twitter4j library files and put it in a folder libs and added compile dependency in build.gradle inside app folder
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'org.twitter4j:twitter4j-core:4.0.2'
}
but I am still not able to use this library
In the Gradle drawer to the right, could you hit the refresh button to see if that helps? Also, the dependencies block that you've pasted above doesn't contain a directive for twitter4j - did you happen to simply miss it out in the question, or is it really missing from the gradle.build file?
Try to add this at "repositories" on your buildscript.
repositories { mavenCentral() }

How do I include dependencies in my android library

I am writing an android sdk and I now want to distribute it but I am having problems with its dependencies. I am using gradle and android studio.
My sdk has a dependency on volley and gson and I have them added as jars with in my sdk. When ever I try to create an aar or a jar to use within a separate client app I always get a crash when ever my sdk tries to reference volley as it wasnt included in either the aar or jar.
Any ideas on how I should be doing this? I have looked into creating fat jars with out much success.
I have also tried using remote dependencies like below but even after a gradle build in the client app both volley and gson are still not included.
This is currently what I have in my sdk build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.code.gson:gson:2.3'
}
then with in the client build gradle I have
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'mysdk-1.0.0', ext:'aar')
}
I am using ./gradlew clean build to build the aar and jar of my sdk
Can anyone tell me the correct way to include dependencies in my own lib?
If you wish to include the transitive dependencies of your library in your client app, you'll need to create a proper maven compatible package that contains a pom.xml. This pom will describe the dependencies of your lib, so that client can pull those deps transitively when they include your lib.
See this tutorial: http://blog.blundell-apps.com/locally-release-an-android-library-for-jcenter-or-maven-central-inclusion/
You don't have to upload the artifact anywhere during development, just use your local maven repo as a target, and have mavenLocal() as a repository for your client app.
This way, you'll be able to refer to your lib as a standard maven dependency using
compile 'com.mysdk:mysdk:1.0.0'
In your client, change your dependencies block like so:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'mysdk-1.0.0', ext:'aar') {
transitive = true
}
}
This should pull in your transitive dependencies as well.

Categories