"Unknown SDK home path" in Android Studio - android-studio

I had to switch the user account on a Windows 10 PC (a very long story). Now, I am unable to open Android app projects as Android projects. I cannot even create a new Android project. I think that I have found the culprit, but do not know how to remedy it.
Start Android Studio > Configure (under Quick Start) > Project Defaults > Project Structure > SDKs under Platform Settings:
I do not know why it shows Unknown SDK home path. This is Android Studio 3.0
Could anyone offer a tip on how to deal with this?
[Update (2017-11-27)]:
The problem has been solved by:
File > Settings > plugins > Enable "Android SPK Support" and a few other relevant plugins.
Do not know why there were disabled.

I think as it is another User on Windows, Maybe the environmental variables path setting might be in User Variables rather than on a System Variables.
Because System Variables meant for all Users whereas User Variables are restricted based on User.

Related

ionic capacitor isn't generating run config for the android emulator

I'm follwing the guide in this section: https://ionicframework.com/docs/developing/android#running-with-capacitor
However, when I get to:
In Android Studio, click the Run button and then select the target simulator or device.
Which I'm getting to by issuing npx cap open android, I can't click 'run' because there's no run configuration. If I try to Add Configuration I can't select my app directory (or any directory) as the module - it just says <no module> in the dropdown.
Is there a step I'm missing or something that causes this? Thanks!
For anyone this may benefit, in my case I had installed the Android SDK platform but not the requisite SDK tools. There is a second tab in the Android Studio > Settings > Appearance & Behavior > System Settings > Android SDK menu called SDK Tools. You need to make sure you also install the correct tools from there.
To get the run configuration I believe you at least need the Android SDK Build-Tools.
Managed to fix it, you should ignore the sections on creating a new virtual device if you have one already. In essence the issue was that my AVD was v28 and my SDK was v30 so it wasn't compatible hence no config.

Your SDK location contains non-ASCII characters - no Android in Tools Menu

I've just downloaded and installed Android Studio but there is no Android submenu in Tools menu and no AVD Manager icon on the instrument panel. When I start SDK Manager, there is an error message:
Please specify a Android SDK location
SDK Manager screenshot: "Please specify a Android SDK location"
If I click on Edit link next to Android SDK Location field, there is another error message:
Your SDK location contains non-ASCII characters
SDK Components Setup screenshot: "Your SDK location contains non-ASCII characters"
I studied these somewhat similar questions, but non of them helped me:
Your project path contains non-ASCII characters android studio
Unable to install SDK tools component while installing Android Studio
unable to install or locate android sdk in android studio
NO Android option in "tool" menu, and no avd manager
I see that the path really contains non-ASCII characters, but is there any workaround other than uninstall Android Studio and then install it from scratch to some other directory like С:\Android\SDK?
UPD:
it seems there is no such workaround at this time
As a matter of fact at the moment there is no other way than to re-install Android Studio to some other directory with no non-ASCII characters and blank spaces, like С:\Android\SDK
I guess you've solved this by now but I ran into the same problem today and after a little research and some annoying tries I solved it. What I found out is this:
Using mklink function you can create a junction to a location but it will not boter if you are creating a it to a non existing location(that's the "file not found" you were getting). And you are creating a junction to a non existing location in this case due to C:\Users\username\AppData\Local\Android\Sdk should(not sure about this) be created by the Android Studio Setup Wizard during installation. In order to solve that, you should create \Android\Sdk in C:\Users\username\AppData\Local and it's done.
The installer does not show junctions to non existing locations in the Sdk install location so if you don't create the folders you can't select the link.
Finally but not less important, the installer does not allow the Sdk to be installed in a folder in the root directory C:\, so you have to create the junction in any other directory but the root one or move it if it's already there(that's what I did).
As I was writting this the installer was running and when it was done I came across the exact same problem with the location to store Android Proyects, and so the same solution to the installer must be aplied to the Save location in the New proyect step.
This is exactly what I did:
1) Create \Android\Sdk in C:\Users\username\AppData\Local\
2) Open cmd as admin and enter the following command:
mklink /J "C:\..\android-sdk" "C:\Users\username\AppData\Local\Android\Sdk"
It will return this:
C:\WINDOWS\system32>Junction created for C:\..\android-sdk <<===>> C:\Users\username\AppData\Local\Android\Sdk
Note: android-sdk is the name the junction will have, you can name it as you like and \..\ reffers to the folder where you want to put the it in, make sure there are no non-ASCII characters in the folder's name anyways.
3) In the Sdk install location, select C:\..\android-sdk and the installation will be ready to go.
4) Repeat the process for the Save location for new proyects, just instead of C:\Users\username\AppData\Local\Android\Sdk use the location you want the proyects to be stored in.
Didn't try moving the junctions files but I suggest you don't, I guess that could get the paths lost and mess up the installation.
Hope this is usefull and good luck with your proyects!
If you don’t want to reinstall the Android SDK in another location you can also create a junction point which is a link to the actual location. You can use the junction tool to do this.
For example, you can create the directory C:\Android and then create the junction SDK and claim the SDK lives there with
Junction C:\Android\SDK C:\Users\Whatever\actual\location
The operating system will show the same contents under both paths and applications will not know the difference.
Hey I had the same problem here but I was able to fix it by just changing the directory to a new folder directly on the hard drive.
Hope this can help.
In my case since I have a Windows 10 operating system, and my sdk was located in Program Files. Having spaces in the directory caused some sort of error, to solve this I used mklink to create a junction called android-sdk in the C drive that pointed at the directory where my sdk was located.
If you can't find the sdk in
C:\Users\username\AppData\Local\Android\Sdk
I suggest looking at
C:\Program Files (x86)\Android\android-sdk
then trying
mklink /J "C:\android-sdk" "C:\Program Files (x86)\Android\android-sdk"
Afterwards open Android Studio go to Project Defaults > Project Structure > Android SDK, click on the "..." button to browse for your sdk and select the junction you just created. Or if you still haven't setup android studio because of this issue, open the application as administrator select the theme settings and all that, and when you reach the setup sdk section, click on the "..." button to browse for your sdk and select the junction you just created.
Important to run Android Studio setup as administrator otherwise you may experience issues downloading components, if you still have issues it might be your antivirus blocking the setup.

How to save and restore Android Studio user interface settings?

Android Studio allows the user to customize certain features, such as editor settings and coding styles. On Windows boxes, the default folder for these settings appears to be C:\Users\{username}\.AndroidStudio{version}\config. I'm looking for documentation for these files so that we can decide which files should be under version control.
The goals are: 1) to have consistent UI settings for a group of developers; and 2) to have an easy way to configure a new Android Studio install.
So far, the following files look interesting:
...\config\templates\user.xml User-defined code templates
...\config\options\editor.codeinsight.xml Editor settings & code insight
...\config\options\editor.xml Editor settings
...\config\options\cachedDictionary.xml User additions to spelling dictionary.
...\config\codestyles\Default_1_.xml Code formatting
You can go file > Export settings then you get to choose exactly the settings to export and you get a single settings.jar file.
The reverse process is file > Import Settings > choose settings.jar
It seems that the user interface has changed since the last answer.
Now as of Android Studio 4.2 Bata 1 on Windows
You have to go to File -> Manage IDE Settings -> Export Setting to see the same window.
If you can't find the File > Import Settings menu, try accessing File -> Manage IDE Settings -> Export Setting.
There may be differences on the version or operating system.
On Android Studio 3 on Mac, it was configure > Export settings, resulting in a settings.zip file.
Because this is so badly implemented, in case you selected some custom folder and now the export button is disabled: you also need to manually specify a _name_.zip, the Android Studio is incapable of doing it itself, ex: x:\settings.zip
It might be obvious, but it did gave me a small headache this morning.

Wrong build being deployed on Android device using Visual Studio 2012 Xamarin.Android

I am using Visual Studio 2012 and Xamarin.Android Beta release to develop an Android application. When I try to deploy the android application for debugging purposes onto an Android device, it deploys the previously built application on the device and not the recent changes I made and deployed (i.e No refresh of build). However, if I use Xamarin Studio to do the same, it deploys the correct build everytime (i.e refreshes the build with new code changes).
Any idea why this is happening?
Thanks in advance!
I had a similar issue: With Visual Studio 2019 the debug version of my driver was deployed while building the release version.
The cause of my problem was, that in the Properties -> Driver Install -> Package Files I had an absolute path pointing to the debug version of my driver in the column File. This setting is valid for all configurations (not separated for debug/release), and when entering macros, they are immediately expanded to absolute paths.
I fixed this by editing the .vcxproj file with my favourite editor and changed the path back to $(TargetPath).
I had the same problem. My solution was to add "deploy" to the build configuration:
BUILD => Configuration Manager... => (select "Debug" from left-hand combo-box) => (tick "Deploy" in grid)
Courtesy of this xamarin forum post.
I have no idea why it does this, I had this issue before. I also noticed that the device log was somewhat behind (ie, at 3.30pm, the last record on the device log was 11.00am).
Uninstalling the app from the device and re-deploying it seems to correct it.
Note: I had this issue in VS, didn't check with XS.
I would look at the difference in your deployment settings in VS and XS (I think it may have something to do with the Fast Deployment option).
Similar question (though for iOS Simulator) here.
I had a similar problem (though on an Android emulator).
What didn't work for me:
restarting the computer
restarting Visual Studio
deleting bin / obj folders
going into Configuration Manager (Debug / Release / Configuration Manager) and ticking everything there - everything was ticked
changing the version of the app in the manifest
What worked for me?
Uninstalling the app from the emulator and then running Debug again.
It was an Android emulator, so I uninstalled by clicking on the app icon and holidng for long, and then dragging it to "Uninstall App". On an iOS simulator it should be similar.

Android Studio - How to Change Android SDK Path

When I open Android SDK Manager from Android Studio, the SDK Path displayed is:
\android-studio\sdk
I want to change this path. How do I do it?
From Android Studio 1.0.1
Go to
File -> project Structure into Project Structure
Left -> SDK Location
SDK location select Android SDK location (old version use Press +, add another sdk)
For projects default:
Close current Project (File->Close project)
You'll get a Welcome to Android Studio Dialog. In that:
Click on Configure -> Project Defaults -> Project Structure
Click on SDK Location in the left column
Put the path to the Android SDK in "Android SDK location" field.
(Example SDK location: C:\android-sdk; I have sub-folders like
add-ons, platforms etc under C:\android-sdk)
Click OK to save changes
Have fun!
Following steps were for older versions(<1.0) of Android Studio
In the middle column Click on Android SDK (with Android icon) OR click + on the top if you don't see an entry with Android icon.
Change SDK Home Path and select valid Target.
From the quick start window, choose Configure, then choose Project Defaults, and then choose Project Structure. Then on the left under Platform Settings choose SDKs. Then to the right of that choose the current android platform, mine was Android 4.2.2 Platform, and delete it using the red minus button at the top, then add a new android platform using the green plus button at the top and point it to your current SDK folder and that is it.
I Configured in this way
on
Welcome to Android Studio Screen
Click Configure Then
Project Defaults and then Project Structure
Then
Android SDK and Selected the path to my current location of Android SDK
Changing the sdk location in Project Settings will solve the problem partially. When Android Studio is used to download a new SDK, it will place the new SDK in the internal SDK folder (inside Android Studio).
Existing android developers will already have a large sdks folder (hereinafter referred to as external SDK folder) containing all the SDKs downloaded before Android Studio came around.
For Mac/Linux users though there is a good way out. Soft links!
Exit Android Studio and perform the following steps:
cp -r <Android Studio>/sdk/ <external SDK folder>/
cd <Android Studio>/
mv <Android Studio>/sdk/ mv <Android Studio>/sdk.orig
ln -s <external SDK folder>/ sdk
And we're good to go. Launch SDK Manager after starting Android Studio, watch as it discovers all your existing SDKs like a charm :).
EUREKA I found it!
With the current Studio 1.3 each project has a local.properties file where you can edit the SDK!
Here's how you can change the android sdk path in Android studio:
Open your required android project in Android studio
Click on the main project folder and press F4
Now click on "SDKs" under Platform Settings (Left hand side of the dialog box)
You should now see a plus sign on the top, click it and choose "Android SDK"
Now you would be asked to choose the required SDK folder
Select the required build target(if necessary) and click "ok"
Now you should see the new entry in the list of SDKs
Click "Modules" under Project Settings
Select your project folder and in the Dropdown for "Module SDK", select the new SDK entry and click "apply"
Now click "OK" and your done.
Note: If changes do not take effect, restarting android studio should fix the problem.
Make your life easy with shortcut keys ctrl+shift+alt+S
or
by going to file->project structure:
it will open this window, where you can select your SDK
Try this way i try in Android Studio 2.0
Step 1: File->Settings
Step 2: Settings->SDK options
Step 3: Click Edit option in Sdk Location
Step 4: Show "SDK Components Setup"
Step 5: Click on Three "..." in "SDK Components Wizad"
Step 6: Select your new SDK Path
I noticed that the latest version of Android Studio doesn't seem to have the option "SDKs" path that's mentioned in many of the answers. I'm guessing that disappeared in one of the updates, somewhere down the line?
The way i solved this issue (osx) was:
Go to Project Settings (Cmd + ;)
In SDK Location make sure you're pointing to the correct SDK location (typically /Applications/Android Studio.app/sdk) then hit Apply
Most important step - hit "Sync Project with Gradle files"
I wasn't doing Step 3 and that was throwing me off. After a sync all your source r belong to us....
goto menu File->Project Strucurt or key Ctrl + Alt + Shift + S
and example http://how-to-android-studio.blogspot.com/2014/11/set-sdk-location.html
You can also create the environment variable (in Windows) ANDROID_HOME to the location of the Android SDK and Android Studio will use that.
Above answers are pretty correct, but some times Android Studio, does not like to refresh after SDK path change, a quick solution is to make some change in you Build file, and click on Sync. It will refresh you project.
Happy coding... :)
While first installation There are two situations either you have pre-installed Android SDK if you had used it in past or you have nothing at all, At a time of installation Installer always ask user how you want to configure SDK with your studio.
You can simply give a path here or browse folder where sdk is available in local system. If you already have SDK, Another option as shown in below picture at Left down corner there is a nice option for download SDK, by clicking it you can download SDK with latest release right from there,You can also use third option see in right down corner setup Android SDK for me by clicking it you can step by step set your sdk.
Although you can also set it up when Android shows you list of available projects, a starting prompt window shown below
That's pretty easy, and also sometime if you want to change your SDK you can always change it right in your Android Studio from
On windows system
File --> Project Structure and then you will see SDK Location Option and from there you can set it up by providing a path or by browse it.
Or if you are on MAC system then from Platform settings.
In Android Studio 2.2.3 I think you can change default SDK location for all projects from the top menu:
File -> Project Structure...
A window like below shows up:
in windows press ctrl+shift+alt+s which will open project properties where you can find first option named SDK Location click on it and there you can change SDK path, JDK path and NDK path also
This may not be what you want, but being an eclipse user I had the same problem having duplicate sdk folders which were eating all my ssd space. Currently you can only change sdk path inside android studio project wide which is annoying. What I did instead was I copied all the previous android sdk files that I was using with eclipse to /Android Studio/sdk/ and then just changed the sdk path inside eclipse.
Now both android studio and eclipse are happy.
Here is some ways, as far as I know now.
Android Studio 3.3.2 (testing is OK)
method: 1
just following steps of the official docs, as bellow link shows
https://developer.android.com/studio/intro/studio-config#jdk
method: 2
following steps of the screen shortcuts, as bellow shows
method: 3
following steps of the screen shortcut, as bellow shows
Tap --> file --> close current project.
You'll Android Studio home page
Click on Configure -> Project Defaults -> Project Structure
Click on SDK Location in the left column and copy the path.
Paste the path in My computer --> Right Click -> Properties -> click on Advanced system settings -> Environment variables and change the android home path.
click on 'OK' to save the session.
Add tools and platforms tools in path and save the changes.
Open command prompt[window+R] and type adb + enter.
In Android Studio you can set the general Android SDK path in the file: %Home%.AndroidStudio2.1\config\options\jdk.table.xml
Click on File menu.
Select Project Structure.
Edit the path in SDK Location text box.
From the next time Android Studio will use this location for all your projects.
N.B.: Avoid having spaces in the path as it may sometimes lead to issues.
This is how its done,in Android Studio for windows
Done
For Android Studio 3.1.2:
Tools>> SDK Manager>> Edit "Android SDK Location" to new location
After that, Set environment variable $ANDROID_HOME to your new SDK location
I had the same problem, but with the sdk path pointing to a mounted drive. I found, that simply quit Android Studio, unmount the device and restart Android Studio made it ask for the sdk location, because it had none (Android Studio Beta 0.8.7).
Therefore I guess if you just quit Android Studio, delete \android-studio\sdk or move it somewhere else and start Android Studio again, it should ask for the sdk location aswell.
Though many of the above answers serve the purpose, there is one straight forward thing we can do in project itself.
In Eclipse, go to Window->Preferences, select "Android" from left side menu. On the right panel you will see "SDK Location". Provide the path here.
Good luck.
In Android studio 1.2.2 you can simply changes project based SDK,
Steps:
Right click on Module and select Open module setting or press F12
Select SDK location from left hand side
Now you can change SDK location as well as JDK location from this page
When I ran into trouble with this on Android Studio 3.1.4 the solution was to go into the app dropdown on my project, then Edit Configurations > Defaults > JAR Application where there is a JRE box on the initial Configuration tab. Setting that to my JRE path solved the problem for me.
Simple Answer Work For Sure...
Step 1: Right Click On The Project>> Select Open Module Setting -->
Step 2: Select SDK Location From the Right Side below image
Step 3: Now browse the SDK location from your computer as show below...
Step 4: Click on OK.
I'm guessing from the responses that people aren't understanding your question... If I'm right in that you want to have ~\Desktop\github\ then changing the SDK location isn't what you're after.
From Android Studio 3.2.1:
From the new project dialog, choose
Configure -> Preferences -> Tools -> Terminal -> Start Directory
Put the folder you want as your project default in the field.
e.g. Mine is set to
~/Desktop/github/
since all my work is in
~/Desktop/github/
Just go to
(Main Menu) File > "Sync Project With Gradle Files"
click ok on the popup, it will change your sdk directory.

Resources