I have downloaded Android Studio and started using it for my Android development.
I need to know, how to open multiple number of projects in a single window like Eclipse. Expecting some help, thanks.
IntelliJ IDEA creates a project for the entire code base you work with, and a module for each of its individual components. So, IntelliJ IDEA module is more like an Eclipse project, and project is roughly similar to Eclipse workspace. There's no exact equivalent to Eclipse's workspace that contains all your work, but you can open multiple projects in multiple frames at the same time.
This table can help you see how Eclipse and IntelliJ IDEA concepts map to each other:
Eclipse IDEA
Workspace Project
Project Module
Project-specific JRE Module JDK
User library Global library
Classpath variable Path variable
Project dependency Module dependency
Library Module library
To use the library add it as a dependancy:
File > Project Structure > Modules > Dependencies
Then add the module (android library) as a module dependency.
Open two projects in a single window is not possible in Android Studio / IntelliJ IDEA. So, when you open a second project, you'll have to decide:
New projects can either be opened in a new window or replace the project in the existing window.
How would you like to open the project?
This limitation is useful because your window offers project specific features, like the Changes tab for VCS information, etc.
How to use library projects?
For now, you can copy the library project into your project folder and declare it as a module dependency. If you use the same libraries in different projects, you will end up having the code multiple times.
ProjectA ProjectB
facebook-sdk/ actionbarsherlock/
actionbarsherlock/ bin/
bin/ src/
src/ ...
AndroidManifest.xml
While this feels kind of inconvenient, it helps having all the required sources in VCS. Soon, Gradle, the new build system, will manage these dependencies pleasantly. Here's an example of how the Gradle build could look like to include ActionBarSherlock or similar libs:
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:library:4.2.0'
}
In this answer you'll find some reasons why this solution does not work yet.
write code in settings.gradle
include ':ProjectName'
project(':ProjectName').projectDir = new File(rootDir, '/ProjectName')
Related
I've found out that over a course of several years, a lot of programs keep seemingly duplicate "project folders" in the Android Studio, why is that?
To elaborate a bit further, if you import their projects, and if you take a look at there folder structure, there is going to be something like this:
Java
|--com.myproject.spaceInvader
|--com.myproject.spaceInvader(test)
|--com.myproject.spaceInvader(alphaTest)
What are these? Something generated by 3rd party testing tools?
When you create a project in Android Studio, it has a standard structure:
From official documentation:
main
Contains the "main" sourceset files: the Android code and
resources shared by all build variants (files for other build variants
reside in sibling directories, such as src/debug/ for the debug build
type). AndroidManifest.xml Describes the nature of the application and
each of its components. For more information, see the
AndroidManifest.xml documentation. java/ Contains Java code sources.
test
Contains code for local tests that run on your host JVM.
androidTest
Contains code for instrumentation tests that run on an
Android device. For more information, see the Android Test
documentation.
When we open a project in the android studio, it automatically starts syncing. What does happen during this process?
The Build window already tell you what they are doing.
First, apply ijinit.gradle, this seems a Initialization Script.
Then apply settings.gradle, it indicates modules needs to include for building.
After knowing what modules should be included, it will load and configure the whole project with project level build.gradle, which is a configuration for all the modules inside this project.
Then it will traverse all modules and apply module level build.gradle for each module, and cross configure them (for module dependencies, I think.)
I am trying to contribute to my first open source project but after forking and cloning from the repo, all files are marked as an error.
Sample error
This is after selecting a source folder.
Current project source
Under package it says: package name does not correspond to filepath
... but I have this
misnamed packages?
Android studio isn't picking up those libraries.
IME there are 2 ways of importing these (I have only had success with the first):
1) copy the source parallel to your own (ie example.com)
2a) include the jar in a libs folder and tell AS to look out for it. (right click will typically provide a good option that I can't recall)
2b) because Android can struggle (ie I couldn't do it, though inroads may have been made since) with importing jars, you may need to use AAR's (android library packages, Android Archive Library (aar) vs standard jar)
However, because this is an open source project, this should all be handled auto-magically for you via the gradle scripts included in the distro.
I am trying to develop an android library and an app using Android Studio. For this, I need to use the library directly in my app project, so I can modify both the library sources and app sources easily.
I am using versions: Android Studio 3.1.2 and Gradle 4.4
First of all, I have tried both methods described in the documentation, but both methods duplicate the library.
Second, I tried to add the library from outside folder as described here, but I get the error:
Unable to find module with Gradle path ':mytestlibrary3-release' (needed by module 'app'.)
My test structure is like this:
In "Workspace" folder I have the app folder "MyApplication4" and library folder "MyTestLib3" containing the library module "mytestlibrary3" (I attached screens)
The application settings.gradle:
include ':app'
include ':mytestlibrary3-release'
project(':mytestlibrary3-release').projectDir = new File(settingsDir, '../MyTestLib3/mytestlibrary3')
and the application build.gradle:
...
dependencies {
...
implementation project(':mytestlibrary3-release')
}
What am I doing wrong here? My purpose is to use the code directly (similar to Eclipse "Add Project to Build Path" or link src folder to source) or to build and use the library as simple and elegant as possible.
I have an Android Studio project to which I've added an ndk module. My ndk module builds and creates lots of different .so files in various build/intermediates directories. However, when I run the app it is unable to load the library .so from my System.loadLibrary call.
Java files that I include in the same module are found just fine so I was expecting Android Studio to 'find' the ndk files as well.
In looking at the google hello-libs demo I see that they have added a step in the CMakeLists.txt file to set the LIBRARY_OUTPUT_DIRECTORY:
set(distribution_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../distribution)
set_target_properties(gperf
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
"${distribution_DIR}/gperf/lib/${ANDROID_ABI}")
and then added an associated reference in app:build.gradle
jniLibs.srcDirs = ['../distribution/gperf/lib']
Adding similar entries to my project allowed it to run properly.
Is there a simpler way to cause an ndk compiled module to be included in the main application? If not, is there a way to do it without having to figure out all the relative ../../ path elements. I guess I was hoping the module CMakeLists.txt would be
the same configuration regardless of what other projects it might be included in but having to know where it's including project is located seems to break this.