How to get Eclipse style code completion in Android Studio - java

I´m just moving from Eclipse to Android Studio and I noticed a small difference.
In Eclipse when I use code completion for example like this
Eclipse would complete the code like this and allow me just use tab to jump to next parameter.
Log.d(tag, msg)
But Android Studio does this:
Log.d()
So is there any setting that would achieve the same result in Android Studio or is this available only in Eclipse

In your IDE go to Editor -> Code Completion and make sure that the Autopopup code completion is checked

Related

How to debug native react native libraries with Android Studio?

This question is NOT ABOUT how to debug the javascript-land of an React-Native app. It is about how to debug native libraries (means: JAVA-Code in this case) in the node_modules-folder.
While it is very easy for me to debug native iOS-parts of RN-Applications with XCode, i stumbled upon various issues with Android Studio...
The main thing is, that the node_modules-Folder is not present after importing the project into Studio, why it is not possible to setup breakpoints to debug thru.
Versions:
Android Studio 2.2.2 (most recent version currently)
react-native 0.38.0 (latest version also)
gradle 1.3.1 (preconfigured from react-native init)
also tried with upgrade to gradle 2.2.2
Android SDKs and -Build Tools from up to Version 23 installed including NDK
How I did it / Steps to reproduce
1. create new react native project:
react-native init debugTest
2. install third party library with native code that you want to debug natively
cd debugTest &&
react-native install react-native-sqlite-storage
3. ensure that everything would work on android side:
launch GenyMotion
launch an AVD
run the application with this command in terminal:
react-native run-android
(this will open up packager and everything else that is needed to transfer the js-bundle).
If one wants to omit this step, it is necessary to start the packager manually:
node node_modules/react-native/local-cli/cli.js start
4. launch Android Studio
with the upcoming starter dialog, choose "Import Project"
select the directory "android" of your project and click on "import"
(these steps are taken from official RN-documentation):
If you want to use Android Studio to work on native code, from the
Welcome screen of Android Studio choose "Import project" and select
the android folder of your app.
5. Android Studio asks to update gradle version from pre-configured 1.3.2 to 2.2.2. I have first denied it for the whole workflow, later on i tried it out (both did not differ significantly for me)
6. One have to deactivate Instant Run due to this issue
7. Click on "Run" or "Debug" in the Toolbar of Android Studio
So far everything works fine. I was able to set a breakpoint in MainApplication.java::onCreate and could step into this method then.
But here are the questions:
The node_modules-Folder isn't present in Android Studio and can't be debugged this way. How to achieve that?
Debugging the onCreate-Method and going further down into the Java-Stack, very offen it happened that the "Sourcecode does not match the byte code".
The debugger was hanging somewhere else in comments of source code but not on exactly that line, which was selected to execute.
Android SDKs:
I have installed all SDKs and build tools and NDK and everything else since version 23:
TL;DR:
How to debug native libraries that are present in node_modules-Folder of an react native application with Android Studio, because they are not visible in AS thus no breakpoint could be passed?
UPDATE
Finally i've found out the root cause. For me it wasn't working due to the fact, that the library i wanted to debug, wasn't shown in Android Studio. But this was a mistake by myself because the library wasn't setup correctly, why gradle wasn't able to take notice of it.
So, this question can be used like a blog post how to do it right (and will be sufficient if the 3rd party library works out of the box with "rnpm-link" or "react-native link") [which wasn't the case here in my example]
Have you done rnpm link or react-native link ? Once you do that, there will be additional modules along with the app module, something like this.
You can look at all the java code in the native module and put breakdpoints , debug etc.
Bam.... i can answer my first of the two questions now by myself. Thx to #agent_hunt, who put me into the right direction...
In this example application the bindings wasn't setup correctly. "rnpm link" and the newer one "react-native link", which is part of "react-native install", didn't worked correctly here for the android-part because it is not implemented in the 3rd-party-library right now, that i've used for this example.
That's why gradle didn't take notice of the library. After setting it up correctly, the folder react-native-sqlite-storage appeared in Android Studio and i was able to pass a breakpoint and to stop the execution there.
Nevertheless, debugging this library works fine, but when i wan't to step into lower/"deeper" methods of android SDK, it still has issues to point to the correct line of code ("Sourcecode does not match the byte code")

Debugging Android Studio 2.2 CMake vs NDK-Build

Today I downloaded the new stable version of Android Studio 2.2.
I want to using c++ debugging in my Android Studio Project.
When I start a new project, with the Include C++ Support selected within the wizard, I am able to create a hello-jniString program which debugs exactly as expected; both java and c++ breakpoints are hit..
However when open an existing project, click the project in the project panel and click "Link to C++ project". It seems to link and compiles changes well ... however, when I try to debug only Java breakpoints are hit :(
Any help into this would be greatly appreciated .. completely baffled at the fact that no real support/documentation exists for debugging ndk and that c++ ndk integration is so all over the place when Android seems so mature ..
I had slightly different case (debugging jni of library module, built by cmake), but you may try this.
Run > Edit Configuration > select 'Debugger' tab
add symbol directory of your debug symbol placed.
in my case, that was LIB_MODULE/.externalNativeBuild
I can debug c++ now but still finding how to turn off optimization option.
Good luck!
Following up on this incase someone comes by this,
I had to migrate Android/Application mk files to CMakeLists.txt.
Linked to c++ project within android studio, and 9 months later ... at last ... debugging capabilities

Eclipse with ADT - Cannot Create New Android Project

I'm totally new to Android development, but I've made apps with Java and Eclipse before. Today I was trying to follow a neat tutorial # KiloBolt (http://www.kilobolt.com/day-1-foundations) formaking and Android game. However, I have this issue that I don't understand preventing me from following along.
Every time I try and create a new Android project in Eclipse, I get to the following screen and cannot press FINISH or NEXT. I have the ADT plugin installed and the Android SDK installed, along with a Java 7 JDK. Eclipse doesn't show any other errors that I know of.
Does anyone know what I might be missing or why Eclipse won't let me create a new Android project?
EDIT: Following Daniel's comment about themes and Android versions, I retried creating a project with the theme set to 'None', but I was still blocked from continuing.
As the comment says, you can't use the Holo Theme with Minimum Required SDK 9. You need at least Minimum Required SDK 14 to use the Holo Theme.
Anyway, you're following a very old tutorial. I strongly recommend you to create a new project with Android Studio instead of Eclipse. It will just work and it will use a more modern structure with gradle (although you will need some time to learn how to use Android Studio)
This is a good place to start: https://medium.com/google-developers/getting-started-with-android-using-android-studio-in-preparation-for-a-zombie-apocalypse-8f42cae10644

Eclipse Cocos2d-x app not change after changing the source

I am working with Eclipse using cocos2d-x 3.4 the problem is when I changing code in cpp files under "Class" folder nothing is changes when I start the app. But the changes are applied in Visual studio also when I change java files changes applied too. Any ideas whats wrong?
Make sure that the [your_project]/proj.android/build_native.py script is executed before you launch the android application.

In Android Studio, method comments not showing in intellisense

I am developing Android application using Android Studio IDE and I can't find any public API comments in IntelliSense list. Do I need to install some plugins?
File -> Preferences -> Editor and check "Show quick doc on mouse move".
Also make sure the option "Autopopup documentation in (ms):" is checked under: "Code Completion"

Categories