How to switch between android source version in Android Studio? - android

Currently it's not very intuitive how to switch between Android SDK source files in Android Studio while, for example, debugging or just inspecting the sources.
I've got the feeling that Android Studio, unlike IntelliJ, is getting the source's version from the compiled SDK version section of the Gradle configuration. But, this is forcing me to debug on a device which is using the same Android version when debugging. If I don't, then the sources won't be in sync with the debugger.
My question: Is there an easy way to switch between Android sources in Android Studio without having to change the configuration in build.gradle?

Try this:
mv $ANDROID_HOME/sources/android-21 $ANDROID_HOME/sources/android-21-orig
cp $ANDROID_HOME/sources/android-17 $ANDROID_HOME/sources/android-21
Restart android studio so it will pick up the correct paths.
Debug
NodeJS program to easily switch the Android SDK Sources which Android Studio attaches when debugging.

I think studio grabs the Android SDK platform source from the targetSDKVersion.
It's wise to update the targetSDKVersion to the latest Android platform SDK from your SDK manager.
It's better for development if your project constraints you from increasing the targetSDKVersion grab the platform SDK your project mentions.
Android platform SDK's

Related

Error when building android APK

I have Android-studio 2.3.2 (which is android-studio-ide-162.3934792-linux.zip) installed, which is the latest stable version. I am using fedora 24. I am using meteor 1.4.4.2
When I build an APK using "meteor build" I get this error:
While building Cordova app for
platform Android: Could not find gradle wrapper within Android SDK.
Might need to update your Android SDK. Looked here: ~/Android/Sdk/tools/templates/gradle/wrapper
It seems to me the path to gradle wrapper has changed on the latest version of Android-studio. I don't have a previous version of Android-studio to prove this though. I've searched for previous versions of Android-studio and could not find them. I have searched for a solution but there is no one out there who seems to be solving this issue.
You will find a solution in this other thread and some explanation in this answer
The explanation is that the linux version of cordova does not search for gradle in the Android studio install folders like for Windows (and even for windows it does not find it if android studion is not installed in c:\program files\android\android studio) or Mac .
On Linux (and maybe for Mac&Windows in future versions of Cordova), you have to install a version of gradle and add it to your path (way to install gradle depends on the version of Linux you're using)
The behaviour was different in the past because android sdk was not inside Android studio like it is now. You could find gradle in the ANDROID_HOME/tools folder.
With recent upgrades, Android SDK structure has changed and it is now part of android studio.
Installing android-sdk_r24.4.1-linux.tgz which installs version 25 or higher version by default solved the problem for me. Because I could not find a way to uninstall Android Studio I had to uninstall and re-install my linux.
See https://gist.github.com/rolandboon/0a5abe1d9c6c515c59ec for downloading and installing the sdk

What is Android SDK build-tools, platform-tools and tools?

I know that this is a pretty basic question. But I am new to native android development and I am having trouble wrapping my head around what is what.
I am using the Android Standalone SDK and not using Android Studio so please guide be accordingly.
Let's say that I want to build my app for API level 19. what level of platform tools and build tools do I need to install.
This is what I have currently
As I want to build for API 19, which I have installed. Do I need to have version 19 of Android SDK build tools or they can be higher?
Kindly please explain to me what each term means as well in laymen's terms.
-Thanks
Build-Tools is a component
of the Android SDK required for building Android apps. It's installed
in the /build-tools/ directory
So, build tool is to build your android app. That is like the makefile for C projects. Output is an APK file.
Android SDK Tools is a component for the Android SDK. It includes the
complete set of development and debugging tools for Android. It is
included with Android Studio.
So, Platform tool is where all the tool to interact with the android device you have, such as fastboot and adb. For example, to install your apk into the devices, run it, debug it, and grep some file from it, you need to first connect your device to adb bridge and run all those command on it.
Let's say that I want to build my app for API level 19. what level of
platform tools and build tools do I need to install.
Basically, you should have all the latest thing here. If you are deploying for a API 19 device, you should also have the Android SDK platform 19.
I haven't touch those things in a while, because I install all those things anyway, so I'd appreciate correction.
Android SDK Build-Tools is a component of the Android SDK required for building Android apps. It's installed in the /build-tools/ directory. It includes the complete set of development and debugging tools for the Android SDK like emulator, sdcard, sqlite and apk builder etc.
For more details check Android SDK Build-Tools
Platform-tools are used to support the features for the current android platform including adb which is acting like a bridge to communicate with emulator or device.
You can also know more about this topic by clicking here
This may be old but i appreciate it. I build apk via the command line so I was thinking with this answer, I may not need the Platform-Tools.
By the way, we are on Android 12 already - API Level 32 :)

Debug native code in Android Studio

Google I/O 2015 promised debugging native code in Android Studio. To do this, you need to install ndk-bundle through SDK manager and update Android Studio to the latest version (Canary branch). And what to do next? How setup? Here is a link to the source. Source
Update June 2016: In Android Studio 2.1 the default run configuration supports native debugging so there should be no need to do the below unless you're using an older version.
For older versions:
Here's how to debug native code in Android Studio:
Go to Run->Edit configurations
Click the + sign
Choose 'Android Native' as the configuration type
In the Module dropdown choose your app's module
Add breakpoints to your C/C++ code
Run->Debug...
The app should be deployed and the lldb debugger will attach after ~10s.
Note: When creating the debug configuration under the 'Native Debugger' section you can choose gdb, however this is less well supported than lldb and known to be buggy. Use at your own risk.
Actually, the advertised NDK support isn't available yet, even if you download the ndk-bundle and update Android Studio to the latest version in the canary channel (1.3-preview3 as of now).
The SDK tools team said that the NDK support wasn't part of the first previews of Android Studio 1.3. However it should be out soon - they recently mentioned mid-June as a target.
update: the debugging support is out now. It wasn't the case at the time of the initial question - thanks for all the downvotes since then :) please look at donturner's answer below.

How to update Android NDK in place?

I used to download the Android NDK as new version were pubished to the devloper website.
It appears Google has recently updated the developer website and removed direct NDK download links, and replaced them with a a bunch of circular references that eventually lead to the SDK download. The SDK download page does not include the NDK. The closest I have found to a download and NDK is Download Android Studio and SDK Tools.
Running $ sudo /opt/android-sdk-macosx/tools/android does not offer a way to update the NDK.
How do I update the NDK in place using the existing NDK or one of the SDK tools?
Or where is the download of the actual NDK located?
To be clear, I use ant and ndk-build from the command line. I don't use Eclipse or Android Studio. Eclipse and the Android plugin is broken; and Android Studio does not really support NDK and JNI.
Plus, I don't really want to learn another editor since I kind of know Eclipse, and I know already how to do it from the command line (so there's no need for an editor).
In Android Studio, go to Tools (top-menu item) > Android > SDK Manager
Click SDK Tools tab
Scroll down and you will see NDK as an option, with detail if an update is available

ADT Plugin disappeared in Eclipse

..I was trying to install the Google Cloud Messaging for Android Library, from the Extra in Android SDK Manager.
Since it did not appear, I updateded the Android SDK Tools and the Android SDK Platform-Tools to the last release (as shown here: How Google Cloud Messaging Service in Android Works?).
Once updated both, I still could not find any Extras--> Google Cloud Messaging for Android Library (just "Intel Hardware Accelerated Execution Manager"). So I updated Eclipse (version 3.6) too (Help->Check for Updates), but nothing happened except for the fact that the ADT plugin was not there anymore: no Android menu under Preferences, no possibilty to create Android projects and so on.
I uninstelled the plugin, removed the files from the plugin directory, installed another version of Eclipse (3.8) with the addition of the plugin but nothing changed.
Any ideas?
I'm working on a Mac OS X Leopard.
The problem was that the new ADT Plugin (v20) requires Java 1.6.
So, first of all, I had to change the Java Preferences, bringing up the 1.6 Java version.
Then, since my Eclipse was set for Java 1.5 32 bit, I had to download the 64 bit Eclipse release (because my 1.6 Java version was 64 bit).
And everything worked again.
Hope this can help.
Beginning with ADT 17 "Java 1.6 or higher is required for ADT 17.0.0."
http://developer.android.com/tools/sdk/eclipse-adt.html

Categories

Resources