Unable to build Demo Project in Android Studio 2.x - android

I downloaded the Navigation Drawer demo described in the docs that is (as of this writing) available here: http://developer.android.com/shareables/training/NavigationDrawer.zip
The zip file for this project does not contain a build.gradle file and seems to use a different structure than is conventional. My guess is that this an old project but I want to build and run it in Android Studio 2.x (currently 2.2.3). Since this is part of the official documentation I guess I might be doing something wrong, or did the creator of this file intend for me to create a gradle build file on my own?
Any help for getting this running?

Whenever you import an Android project you should essentially go to menu File > New > Import Project. As a result, it will automatically create a build.gradle file in case it does not exist in the project.
I'm using Android Studio 2.3.
Hope it helps :)

Delete all gradle related files out side your app folder and import project again it will rebuild and it will include all gradle related dependencies again

Related

How to import a library project in Android Studio, without making a copy?

OK I know people have asked this problem thousands times, but Android studio is so so so hard to understand and use and I still can't find the correct way.
I find several solutions, but all of them says to copy the library codes into main project. It makes no sense to me. When I try to build a standalone project for the library, I find no "New project from existing source" like that in Eclipse.
Can I have a step-to-step for:
I have a main Android Studio project
I have an Eclipse Android library project
Without making a copy of library project
I can let the main project "use" library project
The point is, if I have many app projects using the same library source, I can just modify one copy. If I need to put library codes in every app project, it's a disaster. Eclipse can do this without any problem.
Thank you. I'm really exhausted with Android Studio, but I can't choose to stay on Eclipse since Google says ADT won't be supported anymore.
The real answer to keep your library project only in one place is in this post :
Android Studio 0.8.1 Creating Modules without copying files?
In Android Studio Project import your eclipse library project as new module. Then in Android studio right click on your app module go to module setting > select dependency tab > click plus> select module dependency > select library project module.
new Module or import Module under the project,
then open Module Settings--》Module dependencies --》‘+’ module dependencie.

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....

Run Facebook SDK sample apps in Android Studio

Novice question.
What is the recommended way to run the sample apps, included in the Facebook SDK, in Android Studio (0.8.6)?
The ideal answer would include step-by-step instructions.
I'm using Android Studio version 0.8.0, and Facebook SDK 3.18.
When I tried to open a sample as a separate project, it can't find Gradle and wasn't able to run it. However, when I imported /samples folder as a root, all sample projects were imported and was able to run each samples.
File > Import Project > Select FACEBOOK_SDK_PATH/samples > OK > Create project from existing sources
and then, click next/ok as Android Studio's default setting.
Hope it helps!
Suposing you already downloaded and unzipped the SDK.
Create your android project. Gradle based.
File -> Import Module. Navigate to the unzipped folder and select the unzipped folder.
Add the library dependency in your main module (the one created with your project) adding this line in your build.gradle:
Synchonize project.
If you want to continue creating your own app, you might add the dependency module build.gradle file:
android {
dependencies {
compile project (':facebook')
}
}

How to import google code project to android studio?

I recently came across a cool project (https://code.google.com/p/android-wheel/) I would like to import to android studio. Is it possible to import this without trying to copy-paste individual code?
Thanks
you would have to extract the apk to make it easier, or if you just want to run it the apk is located in the downoads section
Those projects contains .project and .classpath files. Those are meta-data for eclipse IDE and unfortunately there is no build.gradle so it cannot be imported immediately in Android-Studio.
The best thing to do is to write a build.gradle yourself for this project and then opening it into Android-Studio. It's a good exercise to learn gradle if you are not familiar with it yet.

Being told project is not using the gradle build system when it is

When I open my project in Android Studio, I always get this.
Back when Android Studio first came out, I went through this process so the project should have the Gradle build system. There is a build.gradle file in the root of the project.
I can still build and run the project, but I don't understand why it always says this since the project should use gradle build system. Any help with this would be great.
The android studio support two "build mode". one is "legacy" and one is "gradle based". If you are using an very early version of android studio, probably you are still using the legacy build mode. You need to re-import your project using "gradle mode" then this warning will be gone.
To do so, select "file/import project", select your project root directory, and in the next dialog choose "Import project from external model" and select gradle. Then, you may choose "gradle wrapper" or use your own gradle distribution (1.8 for now[12/2013]).
This link can help, https://developer.android.com/studio/intro/migrate.html
Import as a Project:
Start Android Studio and close any open Android Studio projects.
From the Android Studio menu click File > New > Import Project.
Alternatively, from the Welcome screen, click Import project (Eclipse ADT, Gradle, etc.).
Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok.
i know this is an old question but is still valid with newer versions of AS.
If you try to import and import againa and still have the same issue, check if there's a gradle.build file on the root directory, if there's not just create one.
In my case I had to migrate an old project to the new version because with the 0.4.4+ version it stopped recognizing it, and it kept failing, and that was the problem.
Curious thing is the top level build.gradle file just contains this comment:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
I fixed this issue with the following steps:
Make sure that the following two files are in your project directory. If not, create a new one with reference of your other Android projects. These are default auto-generated files.
settings.gradle
build.gradle
If it is still showing any errors when you open your project, restart your project by selecting file/(invalidate /restart).
import Project
File --> New -->import Project
In my case the the problem was that studio version I am using does not support the gradle version of file, so in build.gradle I had to change the gradle version to 2.3.0 and everything is smooth now

Categories

Resources