How do I run MyLocationDemoActivity.java? - android-studio

How do I run MyLocationDemoActivity.java? I got this file from GitHub this is the link:
https://github.com/googlemaps/android-samples/tree/master
I am completely new to Android Studio, what are the steps to run this file?
On the getting started subtitle when you scroll down on the GitHub site, it tells says to create a file on the "root directory" called secure. properties. I am sorry, but I have no clue what or where the root directory is located and how to create the file. But I did get an Google Maps API key.
I also did import the project, but how do I add an emulator. I have downloaded the emulator and it works because on a different project I created a Google Maps Activity Project and just ran the sample code putting a marker on Sydney. I am not sure how to add the emulator to the project I downloaded from github though. I tried to add a template configuration for an android app, but it says no module. How do I add that? In summary, I am just looking for a step by step way to run this file.
(Also, I am sorry if this seems like a mess of questions, but I really have no idea what I am doing)

You question sounds too generic, so I will give some suggestions:
demo activity could not be run separately, you have to create a full environment of android and open the main activity, then open this demo activity
Don't use emulator for developing Map features, use a real device. In fact, I always use "Real Device" when developing, because "emulator" seems lots of bug, and its speed is very slow.
when studying a new tech/skill/feature, bit by bit. e.g.
3.1 you should know some knowlege about android main activity, android basics
3.2 play with emulator and real device, and know adb commands
3.2 play with DemoActivity
good luck!

Related

Xamarin iOS splash keeps loosing images

This is a weird problem. I created a storyboard to use for our splash screen. It has 2 ImageViews in it. I do a build and everything looks.
Every so often, for some unknown reason, the images will stop displaying. Sometimes it's one of them and sometimes both. What's even stranger is that the images continue to display elsewhere in the app.
What I ended up doing is creating a copy of the images so now there is background.png, background2.png, logo.png and logo2.png.
So when the image stops displaying, I switch to the copy and then it works right.
This has been a work around but is not a solution. I can't seem to figure out what the issue is.
What makes this even worse is, sometimes it happens when I change to an ad-hoc build and then deploy to TestFlight so we don't see the issue until we install it from TestFlight.
Unfortunately I've seen this issue before on a couple of the projects I've worked on in the past. it's a strange situation where resources aren't copied accross to the build folder on the mac, most likely caused by something not working correctly with the Xamarin build process for that specific project.
The solution that I've used in the past is to simply delete the 'mtbs' folder that is situated on the apple Mac that you are building/compiling your project to.
The location can be found below:
~/Library/Caches/Xamarin/mtbs/builds/[Long project Guid]
The long guid can be seen in the output window in visual studio when you build your project, but if this is your first project you may likely only have one folder here.
If you simply delete the folder that relates to your project, and then run 'Rebuild', it should push across any necessary resources that it was missing out before, including images.

I cannot run Daydream ndk sample Controller Paint

I am getting started with Google Daydream C++ apps (NDK). I am following the steps to run the Controller Paint App from this official guide
https://developers.google.com/vr/android/ndk/get-started
At the beginning I've opened ndk/demos/controllerpaint as the guide says but this way Android Studio did not recognise it as a project so I've imported the entire gvr-android-sdk folder and things looks much better. However ndk-controllerpaint is still not appearing as a target app.
Does anyone experience this?
Note: I'm using GVR Android SDK v1.60.0 which is only two days ago
After some hours I've realised that there are a few steps that may be easily overlooked
As I wrote in the question does not import ndk/demos/controllerpaint directory to AS but the entire cloned directory (gvr-android-sdk)
Run ./gradlew :extractNdk as explained in "Treasure Hunt sample app" section
Uncomment this line in settings.gradle
include ':samples:ndk-controllerpaint'
Rebuild (or re-open the project)
Now ndk-controllerpaint is in the target app list and is able to run
Hope it helps someone else

AdroidStudio 2.2.2 Empty Activity Error on phone

I just started learning about Android development, so this one is a serious issue for me: I launch Android Studio (2.2.2, but had the issue since 2.2.1) on Win10, make a New project, just keep clicking Next without changing anything (selecting Empty Activity as the template), Finish, try to Run 'app' on my phone and consistently get this error:
Error while executing: am start -n "com.example.android.myapplication/com.example.android.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.myapplication/.MainActivity }
Error type 3
Error: Activity class {com.example.android.myapplication/com.example.android.myapplication.MainActivity} does not exist.
Error while Launching activity
Being a complete newbie who was just supposed to change some text in XML and run the app on a phone, I have no idea what to do or edit to make a pregenerated app actually work. I searched StackOverflow for a more general approach to these errors and tried:
Restarting AS/computer
Disabling InstantRun
Messing with Clean/Rebuild/Synchronize/Sync with Gradle
Deleting .gradle and .idea folders and Syncing with Gradle
Some other obscure shenanigans with build.gradle and AndroidManifest
Various combinations of the above.
... None of which worked (or affected the problem in any way, in fact).
Other observations:
The app isn't even installed (checked All apps, there isn't any com.example.android.myapplication or MyApplication app on my device)
On the development course forum, it was suggested that com.example.android.myapplication/com.example.android.myapplication.MainActivity should only read com.example.android.myapplication/MainActivity. So far I haven't been able to figure out how to change that.
Update 1 New attempted fixes (neither of which worked):
Specified activity directy in Run/Debug window.
Specified no activity whatsoever (doesn't show that error, but doesn't run anything either).
Did File/Invalidate Caches
Changed android.intent.category.MAIN to all-lowercase and back.
Added "category android:name="android.intent.category.DEFAULT"/" to Manifest
Update 2 Managed to run the app on emulator. It seems to be working there, so the error will likely be somewhere between AS and the phone (Android 5.1.1, API 22).
Developer options and USB debugging are on (confirmed the pop-up message, too)
Driver is up to date (AS can see the phone without problem)
Phone is on (and not asleep) while I'm trying to run the app
Any suggestions why the phone won't download and run the app?
In your manifest file edit
with android:name="com.example.android.myapplication.MainActivity"
Make sure that your code doesn't mean any nonsense and that it wouldn't cause the app to crash, which is sometimes the problem. Try finding a problem in code which could crash the app. Maybe in your crash log you can find what causes the crash. Good luck fixing that.
According with your error log I suppose you did not delete previously installed app. See my accepted answer on the same question for details.

IndexNotReadyException when building the application

Writing an android application. It has no errors when I run it on an emulator. But when I tried to build it to an apk file to test on a device, I get the following error.
com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:853)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:802)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:786)
at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:250)
at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:238).......
I seen one similar case raised here which mentions to "Wait till indexing is complete."But I am not sure what I am doing to even interfere with any indexing.
Tried on different computers. Same problem. The only thing I did different before I got this error was to add a dependency at gradle(app) for a RingButton and added that RingButton class to the project to modify it to what I wanted.
As I said it is working fine in emulator.
Just to test if that is indeed the isse, I deleted the class and removed the dependency but the issue is not resolved.
I think this can be solved by creating a new project and moving the files into the new one. Maybe the index is corrupt. But before that can you clear the cache ? in android studio if your prepared to lose some local history then try this:
and then chose invalidate and restart:
I was using Dropbox to constantly backup my project every now and then. So I would click my project and send to Dropbox. I was also instantly clicking run to run the app on my emulator at the same time. During this period, when I mouse over my Dropbox icon, there is an indication that it is "Indexing".
Based on previous answer "Wait till indexing is complete", I can only assume this Dropbox indexing interfered somehow.
Not exactly elegant but I copied each and every file in this project into a New Project and everything is working fine now and able to install the apk file. I didn't change anything so I believe there is some form of corruption in the old project.

Unable to publish node js site to azure using Visual Studio 2013

I am publishing my node js site to azure using this tutorial - http://blogs.technet.com/b/sams_blog/archive/2014/11/14/azure-websites-deploy-node-js-website-using-visual-studio.aspx
I get the following error, as mentioned in one of the comments on the blog, any idea what this error is about and how do I fix this ? I am able to run my app locally no issues with that.
Error: InvalidParameter
Parameter name: index
P.s : the site is like a very basic "Hello world" kind of site, this is the first time I am using and deploying to azure too.
I created a new project as a "Blank Azure Node.js web application", and replaced the resulting package.json and .js files with what I had before, and it publishes fine now
All was working fine for and suddenly got the error! I pretty sure it something in the project as it's now happening on vs2013 and vs2015 on different computers.
Its something to do with Templates after a lot of searching. For me Azure TFS CI got things working again if possible for you?
I had this issue with some projects but not with others, all created in a similar way. So I went thought every change and every setting I could until eventually i worked it out. I didn't want to give up and just remake them.
Basically its file paths, the first thing you notice is that it errors very quickly compared to a usual publish, the first thing that is triggered is a build but unlike heavy framework languages there not really much to actually build.
Like all builds for VS it pops out a bin folder take not of where this appears. This is the key, you want this to appear in the root of your deployment usually at the same level as the publish profile.
Before I moved my projects to VS, TFS and Azure, I used to use git and used the azure push and deployment as part of git, so I instinctively structured my folders in the similar fashion with src folder and all the extra VS baggage in the a directory higher.
This is where I noticed bin folder, so re-structured my solution and made changes to .njsproj (notepad) and moved to be inline with source code and re-added it yo my solution.
Technically speaking this a bug within VS as it allows to create the project and specify different locations which is all fine unless you want to build and publish locally.
Once you get your head around what is going on you should be able to solve this problem easily and not make the same mistake in the future. If anyone is still confused comment and ill grab some screen shots.

Resources