Just migrating Eclipse to Android Studio, and struggling a lot without knowing much shortcuts and import the extended class methods such as "Right Click-> Source->Override/Implement Methods" then we implement methods. Here I found no Source option. How may I include those methods. plz help me to get this quickly, as now I'm typing them .
In Android Studio the menu you're looking for is Code. You then can select what types of methods you need generated.
Related
I know there's some way to do this because i've done it by accident, I just don't know the proper terminology to use in a google/SO search, so my apologies. For instance: the View class, a built in Android class, how can I bring up the file inside Android Studio with all the methods etc to see how the class works? and yes I'm aware I can just go to android.developer.com and see everything, but thats not my question.
I think you're talking about going to the class declaration. On Mac you can hold down Command and click on the class you want to go to, for Windows and Linux you can hold Control and click on the class.
https://developer.android.com/studio/intro/keyboard-shortcuts.html
One of the most useful functions in AS is right-click and 'Find Useage' or 'See Declaration'. For my code, the 'Find Useage' will show all instances of where a function/object is used.
I have the SDK source code in AS too, but I can't 'Find Useage' on that code. Is there a way to set up my projects so that I can use 'Find Useage' on Android SDK code? For example, I would like to go to android/platform /frameworks/.../Configuration.java, right click on Configuration, and see where that class is being used elsewhere.
Failing that, is there a way to find useages short of grepping around the massive SDK project?
Yes, that is possible. You can configure the scope of the search function.
Move the cursor on the symbol you want to analyse, press Ctrl+Shift+a (search for action) and search for Find Usage Setting or from the menu select Edit -> Find -> Find Usage Setting and select Project and Libraries in the scope section.
If the menu item is grayed out, it's because no symbol has been selected.
Furthermore, if you are looking for a particular feature in AS the search for action function is a huge time saver.
BTW: If Project and Libraries is not available it's because there is no usage of the selected symbol in any library.
May be you are looking for this:
Edit->Find->Find in path...
If you are using Android Platforms Codebase directly from the repo, then you can do it. In this case, you will have to update your dependencies by creating another gradle project in your studio where the platform codebase is and then import that in your project.
I'm using android studio and have been able to properly import Robolectric.
When writing code in the test class it responds as though I'm simply using a textEditor.
To give an example of my problem: When I create a POJO I am able to give the constructor a the wrong arguments and the IDE doesn't respond at all.
And i do have the correct POJO import.
Powersave mode!
Put it off and your ide will work as usually ;)
I am having some problem. When I run an console application in eclipse (non-android) I imported google-api-client-googleapis-1.4-beta.jar google-http-client-1.8.3-beta.jar
It work!!
but when I import the same thing into my android application, it fail at new com.google.api.client.http.apache.ApacheHttpTransport(); [ClassNotDef Exception]
Then I follow a lot of the post suggesting a list of library, download all of them, and import all of them.... but it still doesn't should The way I import is right click on the project->config build path -> library -> add external jar file..
So once it switch to android application, it can't find the class. I thought I import the class properly, but since I am having the classNotDef I don't think I am. Anyone knows the reason why????
Any Hints will be good.
Or maybe suggest a list of libraries require for project.
Thanks a ton.
Lawrence
The class you are looking for does not exist in Android's package structure. There are two solutions to this problem:
1: You can check out the corresponding package's documentation and use a different class.
2: On the other hand you can take the class you want and package it with your application. Then it is guaranteed that it will be found.
I am implementing menus using TWL (http://twl.l33tlabs.org/) in an app written using Libgdx. The app runs fine if I don't start any menus, but as soon as I go to a menu screen it immediately force-closes. Menu screens work fine on the desktop version.
In which build path should TWL-android.jar be included (right now it behaves the same in main, android, and both)? And how will the program know to use the libraries from this .jar instead of the default gdx-twl.jar? Will I have to manually implement something in code to use one or the other depending on platform?
There does not seem to be any documentation or sample code of anyone using TWL on android, only mentioning that it can be done.
Running debugger attached to phone gives the following logcat error:
Could not find class 'com.badlogic.gdt.twl.Layout' referenced from method com.Nanners.OptionsScreen.<init>
I think that TWL-android.jar should be added to android project's build path too. Location of .jar is not relevant.
When you add TWL-android.jar. As that is Android specific you can't use it on the core project, so the classes you are importing are the ones from gdx-twl. To make it simpler to explain I will divide it in different escenarios.
You add TWL-android to your Android buildpath. But you use Gdx-twl in your core project. Which isn't added. Thus getting a:
Could not find class 'com.badlogic.gdx.twl.Layout'
You add both TWL-android AND Gdx-twl to your build path. Thus getting duplicated classes and:
Conversion to Dalvik format failed with error 1
Solution
If you use TWL-android classes, you can only do it inside the Android project:
Merge Core, Desktop and Android project. Or
Use Interfacing with Platform Specific
If you use Gdx-twl:
Don't do it.
Actually the best solution is to get rid of all twl stuff and use Scene2d.Ui instead. Its crossplatform and much easier to use.