libGDX - particle effect tool importing to android studio - android-studio

I would like to ask if it is possible to use libGDX particle effect tool if you didn't tick it on project setup at the beginning. I am using AndroidStudio.

Yes,
https://github.com/libgdx/libgdx/wiki/2D-Particle-Editor
You can also just open another project and run the particle editor from there since you can export your effects to anywhere you want and the ParticleEffect does not depend on anything in gdx.tools. Or you could simply import it with Gradle. Just add it to your desktop dependency and re-sync your project.
build.gradle:
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}

Related

Updated android studio and got fail with Gstreamer build

Updated to Android Studio 3.0.0 with new android gradle plugin.
While buildin project got message:
What went wrong:
Execution failed for task `':app:externalNativeBuildDebug'`.
Expected output file at `gst-build-arm64-v8a/libgstreamer_android.so` for target `gstreamer_android` but there was none
but libgstreamer_android.so library file is already there. For native code I use ndk-build. Does anyone have this issue?
Add to build.gradle file of our android module field targets.
android {
defaultConfig {
externalNativeBuild {
ndkBuild {
targets "name_of_native_module_in_android_mk_file"
}
...
}
Don't add gstreamer_android.
UPDATE: Valery's answer works!
Obsolete answer:
That's not the perfect fix, it's just temporary until I have time to take a deep look into the problem. Downgrade your gradle plugin:
File -> Project Structure
Click at "Project"
At "Gradle version" field put:
3.3
At "Android Plugin Version" field put:
2.3.3
Hit "OK"
Accept the messages, sync the project, etc... Android Studio may prompt a windown asking for update gradle plugin again, just don't accept it for now...
I guess the update on gradle changed the way the builds are made, maybe something on Android.mk will have to change or some other parameter on build.grade...
edit: I found some clue at: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
API changes Android plugin 3.0.0 introduces API changes that removes
certain functionalities and may break your existing builds. Later
versions of the plugin may introduce new public APIs that replace
broken functionalities.
Modifying variant outputs at build time may not work Using the Variant
API to manipulate variant outputs is broken with the new plugin. It
still works for simple tasks, such as changing the APK name during
build time, as shown below:...
So, I guess we should keep using the temporary fix (not updated version of gradle)...

Turn on compiler optimization for Android Studio debug build via Cmake

I am using Android Studio 3.0 for my NDK based app.
For the C++ code, I use CMake as the external builder.
This works well, I can create debug and release binaries.
However, I would like to turn on compiler optimizations (say -O3) for a part of the C++ code (the physics engine), not just for the release build, but also for the debug build.
So create the bulk of the debug build as is, without optimizing, yet, I want one of the static library targets to be built with the compiler optimization enabled.
How can I go about this?
I have a CMakeLists for a static library target that gets included using add_subdirectory() directive in the top level CMakeLists file.
Note that I point to the top level CMakeLists in my app's build.gradle file like this:
externalNativeBuild {
cmake {
path '../../Android/jni/CMakeLists.txt'
}
}
It turns out that you can use the target_compile_options() macro in your CMakeLists.txt with a config specification like this:
target_compile_options(opende PRIVATE
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-O3>"
)
This macro adds to the existing compile options.

How to use lombok plugin in Android Studio?

I installed lombok from 'Preferences -> Plugin', but it's not working when I am trying to generate Getter & Setter. My code doesn't recognize it.
Is there anyone having idea how to setup lombok and use it to generate getter & setter annotation?
You need not only to install Lombok Plugin, but also add dependency to build.gradle:
dependencies{
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12' //or v. 1.16.2 in your case.
}
More info on official guide.
Another answer with instructions.
There are so many posts on this subject its bewildering.
I am on the following:
And having torn most of my hair out, trying to figure out
what the heck is going on with gradle top level and project level,
THE ONLY COMBINATION that worked for me was this:
implementation 'org.projectlombok:lombok:1.18.0'
annotationProcessor 'org.projectlombok:lombok:1.18.0'classpath 'org.projectlombok:lombok:1.18.0'
And here is the proof:
My god is it really this complicated to do something this simple.
There's a section related to this on official docs: https://projectlombok.org/setup/android
Follow the previous instructions (Gradle). In addition to setting up your gradle project correctly, you need to add the Lombok IntelliJ plugin to add lombok support to Android Studio:
Go to File > Settings > Plugins
Click on Browse repositories...
Search for Lombok Plugin
Click on Install plugin
Restart Android Studio
Modify your application's dependencies block:
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.22'
annotationProcessor 'org.projectlombok:lombok:1.16.22'
}
Just in case be aware that if your project have mixed Kotlin and Java code - you can't use lombok normal way for now.
Based on this issue: https://github.com/projectlombok/lombok/issues/1169
EDIT:
from kotlin 1.7.20 with K2 compiler it is possible withot concerns.
https://kotlinlang.org/docs/whatsnew1720.html#support-for-kotlin-k2-compiler-plugins
You can use this
dependencies {
compileOnly "org.projectlombok:lombok:1.16.18"
}

Intellij + Gradle: Import classes automatically

I am writing a gradle build file. I want to use the dependency Apache Commons Net v3.3.
Now, whenever I type a statement that uses a class from this dependency, IntelliJ does not recognize that I am missing a import. I was aldo not offered any classes from the previously added dependency. I did indeed click the refresh button on the gradle tab in IntelliJ IDEA, before I added any dangling content to my buildscript.
When I run gradlew now (and it compiles the buildscript), I get a error about a unrecognized Symbol.
Can I do something to make IntelliJ report missing imports to me?
I can add the import by looking up the javadoc online any manually copy-pasting the class name into my buildscript, but I find that rather annoying and I think that such primitive tasks should be done by a IDE.
This is pretty much the exact example:
apply plugin: 'java'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'commons-net:commons-net:3.3'
}
}
task example << {
FTPClient ftp = new FTPClient() //IntelliJ does not complain about missing imports, neither did it have the correct class available in auto-completion
}
Install the gradle plugin (which it seems like you already have).
Go to the gradle tab on the right side of the IDE and click the wrench icon to get to gradle settings.
Check the box that says "Use auto-import"

Using archivesBaseName in a gradle project has no effect

I'm trying to name the artifact that gets built by gradle. Look at this build.gradle:
archivesBaseName='this_is_ignored'
apply plugin: 'groovy'
archivesBaseName='this_is_also_ignored'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.+'
}
I also tried in gradle.properties:
archivesBaseName=`this_is_ignored_too`
In every case ./gradlew build generates a .jar file based on the folder where the project resides (which as I understand it is project.name, I was just hoping to override that with archivesBaseName).
In other words, I want:
~/gradle-helloworld > ./gradlew build
to generate this_is_ignored.jar, but it's generating gradle-helloworld.jar instead.
Any ideas?
(Turning Peter's comment into a CW answer.)
If you set archivesBaseName before applying the plugin, you'll introduce a dynamic property (which gives a deprecation warning). This dynamic property will then shadow the one introduced by the plugin, which is why the second assignment doesn't have the desired effect either. The solution is to only set the property after applying the plugin.

Resources