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"
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.
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 opened android project in android studio and I found that that project contains two manifest files as shown below in the image.
the first manifest contains the activities in the projects while the other manifest contains the permissions!!
please let me know how that is possible and why??
Note: I used to work with eclipse and I have not seen that feature before
image-,
If you look at the directory structure you see two projects: your app and a library project. So one Manifest-file is for your App and the other is for your the Library-project.
The screenshot you have attached shows that you have been created a project and then added a library file for support. Remove the library if you don't need of that.
Right click on project->Build Path->Configure Build Path->Library
Select that library and remove. Now check your project.
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.
Created new project in Android Studio on the desktop.
in the Android view in the Project Explorer all looked normal.
Moved the project to a new folder on the desktop and opened it in Studio.
Now in the Android view in the project explorer there is no dropdown icon on the Java directory.
I have invalidated caches, cleaned the project and probably a couple of other things I have forgotten, still cannot see my source files.
I tried both copy and move using file explorer in win7.
I have faced the same issue, although #Igor answers fix your issue, it was different for me because the Java files are missing in the file directory. Same as you, I've also followed the same steps from https://developer.android.com/training/basics/firstapp/creating-project.html and there's nothing special with those steps.
I have resolved the issue by downloading the SDK quck fix in the "Messages Gradle Sync" explorer.
After that, the java folder will appear to the project explorer.
I've faced a similar issue: I could see my java directory in the Android view, but not in the Project view. I finally managed to fix it by going in the menu: File > Sync Project With Gradle Files.
Hope it helps someone.
Your top-level project in Android Studio should show the absolute path of the directory on your machine. Look in the Project perspective (not Android perspective). Like D:\workspace\myproject. Go ahead and navigate into that directory with file explorer on your machine, and make sure that its java sub-directory contains classes!
If you are using a library project , then you need to add below lines in gradle library level
android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
and you need to change the word kotlin to java according to folder name you already have.