import project from eclipse to android studio maintaining project directory - android

Finally I thought of migrating my android project from Eclipse to Android studio. But importing the project by generating gradle build file from eclipse wasn't helpful. The project structure is as in figure and these are the things I followed:
Generate gradle build file of project in Eclipse. Import Eclipse ADT project. As, you can see from figure Android-project is my main project containing manifest file and resources.
The barcode-common and common contains java classes which are required in main project(i.e. Android-Project). So, I created module or import existing module in Android Studio. In settings.gradle of main-project I written as
include ':app', ':common', ':barcode-common'
And in build.gradle of main-project as
implementation project (':common')
implementation project (':barcode-common')
This works fine. But I dont want common and barcode-common to be inside main-project as I want to maintain the project directory as in figure. So, in settings.gradle of main-project I written as
include ':app', ':common'
project(':common').projectDir= new File('..\\common')
In this case I can't import any java class from common or barcode-common to main-project. Its not recognizing the java class.
So, any alternative or solution for this will be very helpful. I am struggling on this. Thanks
P.S: I want to maintain the project structure as shown in figure as common and barcode-common files are even shared by another project.

Related

Migrate project to gradle error on Android Studio

I just downloaded a project from GitHub to learn from those that know better; Image 1. After extracting the project and importing it to my android studio, it gave me "migrate project to gradle" error.
I have imported using gradle but to no avail.
This is the screenshot of my studio:
Image 2
As per #scott-barta (Original Answer)
The project thinks it's still a non-Gradle based project; it's not the presence of the build.gradle file that makes it Gradle-based, but
it's how the project was set up in the first place.
You'll need to re-import your project to finish the conversion to Gradle.
First, though, it looks like you don't have a settings.gradle file; it looks like you need one. Since you've set up your project as a single-module project, then you can put the file in your project's root directory, next to build.gradle. It should contain this:
import ':'
In the future if you add more modules to your project you may want
to convert it to a multi-module directory structure, but you don't
need to worry about that now. In any event, now you need to do the
re-import in Android Studio:
Close your project, Back up your project, Delete the .idea folder in
the root directory of the project and Delete all the .iml files in your
project. Import your project in Android Studio, and in the dialog
that prompts you for a file, choose the build.gradle file. After
this you should be good to go.
If that does not help, this will guide you through the process: Migrate existing project to Gradle.

I can't seem to implement this github project as a library

I fairly new to android studio and I've been trying to implement this github project as a library by creating a directory called libraries and copying the CustomGauge folder to it. Then updating the settings.gradle and dependencies section of the app. Then I added the specified code to content_main and get the following errors. Any help would be greatly appreciated.
File >> New >> Import Module and load library project , it will be import to your project as a module, and will be add one gradle file under Gradle Scripts.
Sync project with Gradle Files and you are good to go.I hope it will be Ok for you. I tested on Android Studio 2.0 Preview 5

Parse UI not being found when syncing gradle

screenshot of my problem
Hi guys!
There has been a recent problem regarding the ability to import the ParseImageView class in Android Studio and there is currently only one solution: Unable to import ParseImageView - Android.
When trying this solution, it asks to download a ParseUI-Widget file from github and then import that project into my current project and then finally add a dependency for the ParseUI in the build.gradle. When attempting to sync the gradle, the error in the screenshot keeps on popping up no matter where I place the ParseUI-Widget file in the project file directory.
Please Help!
Thanks
Few things to check.
Make sure that this is the content you have inside your ParseUI-Widget.
Move your ParseUI-Widget up one directory. This way it is the same level as app
You also need to edit your settings.gradle. Your settings gradle likely looks like this:
include ':app'
Edit it to look like this:
include ':app', ':ParseUI-Widget'
You have two options:
You currently have ParseUI-Widget within the app/ directory. So you should be including it in your top-level settings.gradle file as :app:ParseUI-Widget, and within your build.gradle as compile project(':app:ParseUI-Widget')
You can also move the entire app/ParseUI-Widget directory one directory up, so that it's in the same directory, side by side with your app/ directory.
From your screenshot, it seems you haven't imported the ParseUI-Widget module. Rather you just cloned the project from github and pasted it in your project directory structure.
What you have to do is,
go in your android studio project structure view,
right click and under new,
click on new module and then
import the ParseUI-Widget as module.
Then those dependencies are in build. gradle will work fine.

Libraries in Android Studio - how not to produce a full copy

I am in the process of migrating from Eclipse to Studio.
I have one Eclipse project which is a personal library of various bits and pieces that I use in other projects. I have successfully imported that library project into Studio.
When I import a project that uses that library, the importer seems to copy the whole library project into the app project, source and all.
This, obviously, is not what is required. I've tried many things and wasted a LOT of time trying to overcome this. So...
Q: Within Studio / Gradle, how do I replicate the Eclipse functionality Project / Properties / Android / Add... to just reference the library project and not produce a stand-alone copy?
You can specify in your settings.gradle a relative path using the project().projectDir property, something like this:
include ':lib'
project(':lib').projectDir = new File('xxxxxx') // Relative file path from your settings.gradle
In this way you can use the lib module inside a project without cloning the code.
Example:
Project0
|--library
|----build.gradle
|build.gradle
|settings.gradle
Project1
|--app
|----build.gradle
|build.gradle
|settings.gradle
in Project1/settings.gradle
include ':library'
project(':library').projectDir = new File(settingsDir, '../Project0/library')
in Project1/app/build.gradle
dependencies {
compile project(':library')
}

Importing eclipse android project into android studio

I am trying to import an android project created in eclipse into android studio. This main project also refers to another library project in the same eclipse workspace. The folder structure is like this:
workspace\app1
workspace\lib1
When I import the main project into android studio, the library project is automatically imported as a sub-project (or shall we call it a module) within the main project. That's not what I want. The library project is shared by multiple apps I am maintaining. It should sit in parallel with other app projects in terms of folder structure. I wouldn't want it to go understand any particular app project.
Please help explain how I can make the library project stand its own and refer to the library project from other app projects in android project. I am fairly new to the gradle build system. So detailed instructions would be highly appreciated. Thanks a lot!
Since you are importing in android studio, I assume you are moving to gradle build system. In your case , I think, it would be best to have a separate AS project for library. Use that project to generate a jar file and then import that jar using gradle build script in each project you want to use it.
If you are sharing the same library across multiple, you can configure them as separate AS project and have "aar" file as output. (In your gradle you put>> apply plugin: 'android-library'). You then define them as dependency in your gradle file. (either through maven repo or putting it in your libs directory and defining it in your dependencies section). You can find more info at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-projects
You can use version control tool such as git to synchronize the library project in every main project. But you need to use a version control tool to manage all your projects first.
Read here on "AS Modules"
review 57.1.2 on "common behavior"
Take a look at a project built on AS pattern of modules as libs used in eclipse (gradle.settings) pictured
all the includes are modules
maybe you can rethink the idea of how to get AS to work for you in reusing code....

Categories

Resources