Anyone know how I can run an android sample app? - android

I'm fairly new to android development using Android Studio. The examples online say to build with Gradle. I choose Gradle when importing the project but then I get an error saying that it is not a Gradle based project. Does anyone know how I can get over this to run it on my phone?

Pick a sample project to import that has build.gradle file in BOTH the app module directory AND the project root directory.

Strongly recommend rather than importing an existing project, you create a new one from scratch yourself, following along with a tutorial.
Here's a really good first tutorial for Android Studio which is recent (August, 2014) as of this question, so it will all be relevant to the current version of Android Studio.
http://www.codeproject.com/Articles/801078/Hello-Android-The-Hello-World-Application
As far as getting the app onto your phone you can either (a) plug in the USB cable from the phone to your PC and run from Android Studio, or (b) email the app's APK file as an attachment to any email address you check on your phone (such as gmail for example). For the email method, you also need to change a security option to allow apps from unknown sources.

Related

How to start Android Device File Explorer without Android Studio?

I am building my app with React Native and do not need Android Studio. I am starting the emulator directly from console. However if I need to check files, I always need to start Android Studio to launch the Device File Explorer.
Can I launch the Device File Explorer directly from console or as standalone in some way?
Many thanks!
No, sorry, that specific tool is an integrated part of Android Studio.
There used to be the Dalvik Debug Monitor Service (DDMS), which was a standalone tool that had a file explorer among other things. Google discontinued that some time ago.
The only official solution that I can think of is to use adb pull from the command line.
Otherwise, you would need to see if somebody created a standalone tool for this, or perhaps a plugin for Sonar.

Why don't we have a single file to open an Android Studio Project?

Why don't we have a file similar to the .xcodeproj (for XCode applications) or an .xds (for Sencha Architect Projects) for our Android Studio Project?
I'm pretty sure a good number of you here have experienced the frustration of trying to import a project you see online in order to piece it apart better and learn how it works. I get that we are supposed to Import Android Projects built using Eclipse and Open Android Projects built using Android Studio.
However, why is it that we have to go through File -> Open -> then pick out the directory of the Android Studio app that we want to open? And the thing is, Android Studio doesn't seem to know it's an Android Studio project until it tries to open and build it. In the screenshot I have below, I have the sample Android Studio projects of ARToolKit, but I've only imported two of them.
As you can see, only those I've imported "can be seen as an Android Studio Project" as indicated that they have the Android Studio logo instead of a Folder.
This can be an issue for those just starting to develop in Android Studio on their own and they try and use existing projects (build from Eclipse or Android Studio) and they hit a snag with just trying to import the projects for reference. They might not know that they should import the folder and not the projectname/src subfolder. It adds to the "steep learning curve" that Android Development has if opening/importing projects aren't streamlined to a degree.
To sum up, my question is:
Why don't we have a single file that we can open that would in turn open Android Studio and import and build the project if it isn't built yet?
Android is not iOS. iOS development is only possible in xcode, hence it makes sense they added a shortcut to open it in xcode directly with a .xcodeproj file. Make life easier for iOS developers.
Android development however can be done outside of android studio as well. Eclipse is just one example, there may be other IDE's that support this. This is possible because android has standalone SDKs and tools that third party applications can use. iOS does not.
Imagine you are working on an android project in android studio. Then your boss tells you someone from 3000km away is going to help you. This guy may be using android studio, but maybe he isn't. When there are multiple options that developers can choose from individually, you do not want to pollute version control with files that you are using, but others may not care about. Each their environment.
This is merely a logical conclusion that you can come to by comparing. The "real" reason why this was done can only be answered by the people that created (adapted intellij) android studio.
This has been very frustrating to me too.
I try to give you a "beta" answer, waiting somebody to confirm it to me.
An Android project is just the composition of many parts that in some cases are concurrent to create the apk file.
It's just like what happens for the whole java projects: you have the main/src/java, the main/src/test, the maver or gradle files, the gradle or maven wrapper, the manifest, the configuration etc.
So you won't have a single project, but a series of folders that can contain many "flavours" or "versions" of the product itself.
The only help it is given to us is the Android studio icon that appears if a folder contains an android project in its subfolders.
I don't know if I have really answered to you, I just have given you my impressions and my thought.

How to make ide in Android like AIDE to compile android project in android phone itself

As I know there is a Software (AIDE) in android that can compile android projects to APK in android phones.
My question is how this works? Is it possible to make DEX file in android devices and pack it in APK?
Yes, you can create a basic level Java/Xml Android App using AIDE.
Step:1: Prerequisites
Install AIDE from Google Play on your Android device (all Android versions from 2.2 are supported) and start it. AIDE comes bundled with a mobile version of the Android SDK, so there is no need to install anything else.
Step:2: Creating the App Project
"When you start AIDE for the first time in expert mode you will see the "Create new Project" dialog. If you have already opened a project the dialog will not show, but you can invoke it from AIDE's integrated file browser by choosing "Create new Project here...". In the create app dialog you first choose the type of project you want to create. For your first app choose "Android App / Hello World" here. A dialog will popup where you can define the basic information about your new app: First, choose a name for your app. Second, choose a package name of your app. Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. Finally, tap "Create" to make AIDE generate your new app project. An app project contains all the files that comprise the source code for your Android app. AIDE will generate these files on your SD card. AIDE will also open two important files of your new app for editing: main.xml and MainActivity.java. By default, AIDE will create a Git repository for your new project. This behavior can be turned off in the settings. See the tutorial about Using the Git version control system for more info.
Step:3: Running the App Project
Running an app project with AIDE is easy. Just select "Run" from the menu. In order to run your app, AIDE will first build an Android application package file (APK) for your app. An APK file is used to distribute and install application software onto the Android operating system. The APK file contains all of your program's code, resources, assets, certificates, and manifest file. You will see a popup showing the progress of the build.
Finally, you can run!
For more details:
Create a Simple app using AIDE. AIDE tutorial
Develop Android apps from within Android using AIDE (video)

Load AOSP Application to Android Studio

I found a few questions asking how to get the source code from the AOSP running in Android Studio. However, I could not find any explanation on how to import only a single application of the AOSP.
I am trying to do it for the Dialer application which can be found here. However, I had only minor success, I was able to import the code as a project, but didn't manage to set up dependencies and required libraries and all that.
Can anybody tell me if it is possible, and if so, how this is done?
UPDATE:
It seems impossible to achieve this with the code that i found and which was part of the full android distribution of google. But google decided to distribute the Dialer application just like any other application via the playStore. So there should be a possibility to find this code, IF it is also running under the open source project.
You can only open the whole AOSP inside Android Studio.
After you finish building the source do make idegen && development/tools/idegen/idegen.sh inside your root folder and then open the new android.ipr in your root via Android Studio.
AOSP code you are looking is not Android Studio compatible, It's an Eclipse project.

Sharing project folder in Android Studio

How can I share a project/working directory between two Android Studio installation in two different computers? The shared repository is a file sharing cloud service like Dropbox.com or box.net.
The reason I want to do this is that I have a desktop and a laptop each with Android Studio. I want to be able to seamlessly do development work between the two systems without having to checkin or checkout code in a code repository.
I don't plan to run the two Android Studio concurrently. This is just for me - one user.
I used to be able to do this with Eclipse ADT but with Android Studio I am getting multiple errors - missing libraries, etc.
Any suggestions on this use case is also welcome.
Thanks in advance,
Ray
It is actually working, to begin with. It was an oversight on my part. I needed to download the latest version of Android Studio (including the updates). Since applying updates I can open the project in another device by referencing the project working folder in the shared folder (in this case Box.net). I just get an initial prompt on the SDK location, that it is unable to find the original location. But it did offer to use the SDK location on the current computer.
When using the current device's SDK folder it will say that it will "modify the project's local.properties file." I click OK on this and it's all good.
This is what I wanted to do. But I'm looking at GitHub now. Thanks.

Categories

Resources