Start Unity project in Android Studio by clicking a button? - android-studio

I'm a student who concerned about this issue, I'd like to create a button and when the user taps the 'Start' button, the app opens the Unity program.
and I've done lots works for this in the past few weeks,I also found this question:
How to make Unity3D as an activity in Android Studio?
this is certainly what I want solve too. But Unfortunately, there is just 1 answer replied.
and I found this way in:
Unity3D and Android Studio Integration (the 2nd answer)
I'm so glad could find this way to try, but there are so many wrongs,May I please someone who can solve my bugs or teach me a better way to do? please!
I reference this answer and do it step by step, and I bullet all the problems which I met as follow:
1.In the step 1 "import new module",I just can choose a gradle file rather than a project folder, is that right?
2.In the step 5,Sorry for that I don't really understand what this means,[Integrate the new unity module's Manifest with your project’s Manifest by moving necessary tags to our project’s Manifest (e.g. :Activity, uses-feature etc.). But I only have 1 Manifest, I don't know how to integrate:
3.In the step 6,I add "compile project(path: ':yournewmodulename')" to dependencies, after that the problems appear.
4.In the last step, I don't know how to create a layout like that, do I have to create a new file before Step 1 ?
5.In the last step,I've try this script many times,but why this important [UnityPlayerNativeActivity] always become gray?
Please any master who can solve them!!! I would be vary very grateful! thanks a lot!!!

Related

visual layout editor does not allow drag&drop

I'am a newby in android studio and learning a lot, but now have a problem where i cannot seem to find the answer to.
In android studio you can visualy drag&drop your screen.
I have seen it can do al lot (although you sometimes need the xml) but for me it is not working at all.
I mean i cannot drag&drop any widgets on the screen at all.
Tried changing the theme: no help (really tried a lot of them)
Tried a complete new project: same story
Tried other APK verion: same story
Tried Invalidatd caches / restart: no help
Even with a new project (EmptyActivity) it add's a android.support.v4.widget.NestedScrollView and then gives error's on that
(Failed to find style 'coordinatorLayoutStyle' in current theme).
It also gives an error on layout_height/layout_with not being there. But they are there for each widget.
Please do not missunderstand: when i execute the project i runs just fine (both on phone and emulator) but the visual builder for the screen.....:-(
Does somebody knows how to solve this.
If more info is needed please ask.
Any help is more than welcome.
There are several things that could be causing this:
Your caches could be messed up. Try going to
File > Invalidate Caches / Restart ... (I know that you already tried this, but posting for future views.)
Also, make sure that you don't have Drag-n-Drop with ALT pressed only checked in your Settings (Appearance & Behavior - Appearance).
Finally, in a default project created in Android Studio, there are two XML files created for each layout. For example, content_main.xml is embedded within activity_main.xml. Make sure that you are using content_main.xml for your design work.
In the end i fixed it by changing the SDK version in de gradle file.
still do not understand why it was wrong as studio genereded it that way but now it works so.... for me: case closed.

Content_Main and Activity_Main in Android Studio 1.4: If I put a button in activity_main, but not content_main, will the java file know about it?

I'm a beginner to android but have done a little with an older version of Android Studio, and in the new version I'm having a lot of trouble getting the java file to find buttons or ImageViews. I'm not sure if it's related to the content_main vs activity_main thing. I'm having trouble finding any answers as to how this works on Google, so I'm just starting here, I want to put a button on the main page of my app and have the java file that correlates to the XML file find it. How do I do this?
Answers online are very vague to me, things like "activity_main.xml will determine how the look of the main activity should be. And on the other hand content_main.xml will determine the contents in the activity_main.xml" does not mean anything to me. Please tell me where to put the button!
If you are adding a button in activity_main rather than content_main it cannot be recognized by your Java file. Not only that is will even not be visible on your app.

Specflow Options in context menu is greyed out in Visual studio

I am using Specflow to write test in BDD style format. Unfortunately today morning in my visual studio, I am not able to see the options to create the step files. Even F12 is not working. Those statements which do not have a step file definition will be in Purple previously. But today it is in Black even though there is no step file definition.
Please see attachment
Could anyone please help me as what I am missing
Thanks
sounds to me like you have not got the Specflow visual studio extension installed.
Are you on the same machine? Have you disabled extensions?
I am not sure what exactly you are looking for. If possible please post complete image of the right click options you are getting.
Scenario steps which do not have step defs will be in pink colour. Once step defs are coded colour will change to black colour.
Image link: http://i61.tinypic.com/2whgjdd.png
If you want to create step def for steps, right click on the step and find Generate Step Definitions or Go To Step Definition options at the bottom. Click any of the option to create step defs.
Image link: http://i59.tinypic.com/2cdihqr.png
Note: Unfortunately I am unable to post images here due to lack of reputation. I am adding links to view the images.
I tried all options which are listed above and some not listed. The last option worked - uninstall and reinstall visual studio.
I faced the same issue in Visual Studio ultimate 2013 as well and it annoyingly took 3-4 hours to resolve it.
I followed the steps mentioned here - http://www.specflow.org/documentation/Troubleshooting-Visual-Studio-Integration/
and tried to delete the "specflow-stepmap-SpecFlowProject-607539109-73a67da9-ef3b-45fd-9a24-6ee0135b5f5c.cache" file but it still didn't work.
Similar steps are mentioned here as well - http://brantleytec.blogspot.com.au/2014/08/specflow-force-step-definition-rebinding.html
After deleting the cache file, when I reopened Visual Studio and the solution, the cache file never got recreated.
However what worked for me was reloading the project. It worked perfectly fine after that.
So here is what I suggest - Delete the cache files and then reload the project.
It is the same thing I experienced before.
The solution was to delete all the files inside bin/Debug folder and restart your visual studio. Hopefully this could help you resolve the issue as it can be extremely annoying.

Android Studio project folders not showing

I am unable to see the folders that are physically existing, this is the case.
But in actual fact I have other folders as welll
So what can I do?
Above your the file directory view in Android Studio is a drop down which currently is most likely set to Android. Change it to Project and you should be able to see all your files.
I tried the all the approaches mentioned above but can't fix rather than fix it by a hardcore approach -
Step 1. Close your Android studio.
Step 2. Delete .gradle and .idea folder from your project directory.
Step 3. Open your project and you will see the files again.
go to View menu then click tool window then after click on project
view->toolwindow->project
it worked for me
for me doing the following works:
from menu go to: View--->tool windows ---> Project
then click the little gears icon (settings) you will see an option to change the empty middle packages. it looks like this:
disable "Hide Empty Middle Packages" under the Project View settings dropdown and then it should make everything show up.
If anyone ever does what I did maybe this will help:
Android Studio does not like it when module names begin with a number. I was learning from some tutorials and named the first module "1-name" and the next one "2-name". Setup was fine and it ran, but only the "Gradle" Scripts entry would show in the navigation window in "Android" mode.

Coded UI Test Builder cannot be started because the file '' is read-only

I have created an new UIMap in my project. I was able to work with it day before this error appeared. Now, when I right click on the new UIMap in VS (Visual Studio) and Click "Edit With Coded UI Test Builder" option - above error pops up.
I tried starting VS as admin, editing the .uitest file in the project folder (bad practice even if you know what you're doing) and saving it (it allowed me to do this), but still won't let me record using the new UIMap.
Additionally the original UIMap still works. I am using different names for UIMap if anyone is wondering.
I am using VS2012.
Any ideas would be appreciated. Thanks.
I have found the problem and A Solution for it, but not the cause. The properties of UIMaps .cs and .Designer.cs files were set to read-only. Please do let me know if anyone does find out what causes this and how to prevent this from occuring in the future.
My Solution:
Right click on the UIMaps .cs and .Designer.cs files in the project folder
Click on Properties
Untick Read-only tickbox
Voilà!
Thanks all.

Resources