I successfully imported a "testgame" project into Android Studio using the build.gradle in the root directory of where libGDX populated the project files.
Within the root directory, I noticed there is an "android" sub-directory that also has a build.gradle file and includes other sub-directories for different files that are specific to android. The different files include assets, libs, etc.
When I try to import that build.gradle file into Android Studio, it does not display the proper class and manifest files needed for the game.
I tried to search for what a successful import should look like in Android Studio, but had no luck.
Has anyone successfully used the libGDX framework within Android Studio?
I tested a demo on libGDX on Android Studio 1.0.2 and it worked, the following link leads to my screenshot showing the version of my AS and the output from an emulator
https://www.facebook.com/yaten.Notes.Android/photos/a.438504762964810.1073741827.438486782966608/438689702946316/?type=1&theater
Sorry, can't post screenshot directly, I need 10 rep to do that.
It sounds like you were right the first time, but then tried to import another file.
The build.grade file in the root of the project is the correct file to select when importing into Android Studio.
This is in line with the official wiki instructions, as Android Studio (at least through the current 1.1.0) is built on top of Intellij.
Once you've imported that project you should automatically be able to run on Android, as a configuration will have already been created.
It is incorrect to import any of the other build.gradle files, such as the one in the android directory that you tried to load.
Related
I try to build and run the sample helloworld/mobile in project (https://github.com/android/car-samples)
My question is about how to select the sample app directory as described in README.md:
Select a sample app directory (e.g. helloworld/mobile) in the Project Structure UI on the top left. Each sample app has two build targets, one for the mobile platform and the other for the automotive platform.
<<<<
I went through Project Structure UI, I tried different possibilities but no way,
Build menu always shows Make Module car-simples-main and when I launch Make Module, nothing happens.
Wondering if something has changed in the last Android Studio version,
I use Android Studio Chipmunk | 2021.2.1 Patch 1
Anyone can help?
Thanks.
First of all, let's understand how the git directory is structured.
The directory has the two folders car-lib/CarGearViewerKotlin and car_app_library, which are gradle projects that can be built using gradle.
How do you know?
Any folder contains gradle wrapper and a build.gradle and settings.gradle files means that they're ready to be built using gradle, and these can contain modules inside of them.
Now helloworld/mobile is a module, or you can view it as a sub-project.
How do you know?
If you open up the parent's settings.gradle file, you will see the line include ':helloworld:mobile' meaning that the directory helloworld/mobile is a sub-project or module for the top level car_app_library project.
Modules by themselves are not runnable, they need to be contained in a parent project with top-level gradle files.
Now the solution for your problem should be: open up these two as projects in Android studio individually: car-lib/CarGearViewerKotlin and car_app_library, it will create a default run configuration for each project.
You won't be able to run helloworld/mobile alone, you'll need to run the parent project car-samples/car_app_library.
However, You should technically be able to open the root directory (the git directory containing all of the projects) and creating a run configurations by hand for each project, and you should be able to run the projects using one Android Studio window opened.
Trying to add opencv to a flutter plugin. I have tried to follow example by Sawan Kumar Bundelkhandi. When I did an import module of OpenCV into the (java) project, it only shows me a name of :Java, not anything like openVClibrary4.0. Maybe that is my first problem.
Later, I cannot add the libs directory to the java project. I tried various right click, create Directory, but nothing seemd to be created. I did a copy in Windows explorer, and renamed it to jnilibs, but I cannot make the Android Studio project see that directory.
Any suggestions where I could look for more information?
I'm trying to import PocketSphinx into a project using Android Studio 1.5.
This page details how to install and use the library. However I stumble at the following step:
In Android Studio you need to place jar file in app/libs folder and jni .so files into app/src/main/jniLibs folder.
My project directory tree does not contain these directories and I have been unable to create them myself. This is my directory tree:
That webpage also provides a sample android studio project, which works just fine, but I think it is designed for an older version of android studio because the directory structure is totally different to any app I've seen before (While I do have some years of coding experience in other areas, I only started developing android apps in the last 2 or 3 months).
This is what it's directory tree looks like:
(I haven't expanded the entire tree this time)
One last thing: I tried to import the library (as available for download here) by using "File -> New -> Import Module" But doing this breaks the project (and it can't be fixed by simply clicking "undo"). The error message I get is:
V:\Documents\ButterflyMilk\SpeechRecDemo\pocketsphinx-android-master\build.gradle
Error:(7, 0) Could not find property 'sdkDir' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#606a97f.
Open File
and at the top of the code view it now permanently says:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
Thanks in advance for any help and advice you can offer! I will also quickly note again that the sample program provided works just fine, and I've managed to tweak it and play around with it. However I still need to be able to import the library into a separate project. Thanks again
My project directory tree does not contain these directories and I have been unable to create them myself. This is my directory tree:
This is "Android" view.
This is what it's directory tree looks like
This is "Project" view. You can switch between views with a dropdown selector on the top of the region (it says "Project" in second screenshot)
I have been unable to create them myself.
You can create folders in file manager.
You can also use IDE, right click on the app, then select "New" -> "Folder (green in the bottom)" -> "JNI Folder" for example.
You can also use "New" -> "Directory".
I have been developing an Android project using Android Studio and Gradle.
My project's AndroidManifest.xml is located under an external folder.
I'm pointing to it using the following code in the build.gradle file:
sourceSets {
main {
manifest.srcFile '..\\..\\..\\sources\\AndroidManifest.xml'
}
}
Everything works great, the project compiles and runs, except I can't locate the AndroidManifest.xml file under the project structure, when using the project view pane.
Maybe I need to add something else to the build.gradle file?
First - I don't see any reason to maintain manifest outside Android project. It's integral part of Android application so it should be in location where Android Studio can read it. Just copy it where it should be.
If you really need to have AndroidManifest.xml in external location, think about making symbolic link to location where Android Studio expects it to be.
I don't believe you can. When you use the project view pane, Android Studio displays all files in the project root, not all the files linked to your project (to test this, you can create a new file that's not linked to your project in the folder of your project and you'll be able to see it in Android Studio explorer).
Android Studio (and IntelliJ), are build under the assumption that all of your source is in a single "project" folder. That is why the Project view only contains files in the project, it's designed to just show a file tree.
I just tested it, you can use the Android view (one of the other options in the screenshot you posted) to have your external Manifest appear. Some of the functionality is disabled or broken while editing though. This is possible because the Android view is meant to show all relevant source for your project, even if you have the odd requirement of an external manifest.
But please, consider moving it into your project directly or using a symbolic link. You'll be much happier.
Put it in a folder closer to the directory you're on or if needed, move it closer. "..\sources\AndroidManifest.xml"
I am trying to get libgdx gradle project to work on AIDE. AIDE is an app on android that acts like a IDE. It doesnt seems to work as the buildconfig.java does not have the package name generated. Anyone have any workaround?
Ok, I've got my project compiling. What I did was...
Created a new LibGDX project under AIDE.
Left all the folder names as they were. i.e. gdx-game, gdx-game-android.
Using adb I pushed all my files into these respective folders. e.g. core = gdx-game, android = gdx-game-android
I also had to copy in a .classpath from another working test LibGDX app I'd created in AIDE previously, as this time round there wasn't one.
Et Voila!
At least it's working for me.
Seems that AIDE's got a new interative course on using libGDX
Here is my solution:
First copy core/src folder to android/src folder
Then copy libs folder from a project to android folder
Only problem i had was libgdx.jar file of Aide was older version.I downloaded latest version of gdx and copied jar files to libs folder.
#thhVictor, "It doesnt seems to work as the buildconfig.java does not have the package name generated"
It's because AIDE tries to treat regular java project (which is LibGdx project named "core") as android project. You can check it youself navigating to core/ directory and see that AIDE shows option "open this Android App project" instead of "Open this Java project". After opening and clicking "run" you'll see your error
You have 2 options:
gradle-based https://github.com/Deepscorn/libgdx-gradle-template/blob/master/README.md#aide
eclise project files based http://deepscorn.blogspot.ru/2016/07/building-and-running-android-studio.html
Both requires to do things by hand. But I prefer gradle-based because it's modern thing and so I hope AIDE devs will make support for regular java projects which are gradle-based