Autocompletion not showing in Android Studio with dual screens - android

I just switched from Eclipse to Android Studio (IntelliJ).
I can't figure out how the autocompletion works! I tried Control + Space, Control + Shift + Space but i have no relevant suggestion. Not in the Java files, not in the layout files.
Is there another shortcut? Do I need to enable some option beforehand?

Preferences > Keymap > Code > Completion > Basic/SmartType:

It was actually a display problem. I'm using two screens, and the suggestions only appear when the IDE is on the main one.
The (imperfect) solution is to define the display where I'm using the IDE as the main one.

Just remove all the folder "AndroidStudioPreview";
On Windows:
Go to your User Folder - on Windows 7/8 this would be:
[SYSDRIVE]:\Users\[your username] (ex. C:\Users\JohnDoe\)
In this folder there should be a folder called .AndroidStudioPreview
On Mac OS X
Remove these files:
~/Library/Application Support/AndroidStudioPreview
~/Library/Caches/AndroidStudioPreview
~/Library/Logs/AndroidStudioPreview
~/Library/Preferences/AndroidStudioPreview

You can get your Autocompletion suggestions back in Android Studio by doing: File>Invalidate Coches/Restart...>Invalidate and Restart

Related

Failed to update Android SDK Package List - Unity 2019.2.10f1

When I try to export the game build for the Android platform, I started getting this error:
Within the Project Settings - Minimum API Level and Target API Level not get loaded anyhow!
While I have used all default Unity provided settings to export Android build.
Here is the image to illustrate this:
Now what to do to solve this error?
I have already read all the threads related to same problem but overall I can't able to find the solution that actually worked for me.
Project Settings > Player > Target API Level: Change "Automatic" to "Android 11" (or else)
Play once and Stop.
Change target api level to Automatic.
I don't know if the problem is the same, but this is how I handle it every time.
Edit: Now I just do this; I open the Other Settings Tab in Player Settings. Error appears in console. I Play and Stop it once and the error goes away (No need to change API Levels)
I just got the same error on MacOS using both Unity 2019.4.18.f1/2019.2.21.f1 and after a lot of messing around I think I might have figured some of it out.
At times ( don't know why ) Unity ( or something else ) starts resetting the JAVA_HOME environment variable to string empty when you start Unity. So even if you set JAVA_HOME via console or .bashrc/.zshrc depending on MacOS version it still doesn't work.
Some posts mentioned adding "/" to the end of the external tools SDK path. I think that just forces Unity to set the path again which makes it work for a while. But for me the the error just came back the second day.
I permanently fixed it adding an editor script to the Editor folder that changes the JAVA_HOME environment variable every time Unity starts/loads.
Here's the method for MacOS, just paste it in a C# script in the editor folder.
[InitializeOnLoadMethod]
static void SetJavaHome()
{
//Debug.Log(EditorApplication.applicationPath);
Debug.Log("JAVA_HOME in editor was: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
string newJDKPath = EditorApplication.applicationPath.Replace("Unity.app", "PlaybackEngines/AndroidPlayer/OpenJDK");
if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
{
Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
}
Debug.Log("JAVA_HOME in editor set to: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
}
This worked for me :- Edit>Prefrences>In JDK Click copy path> then Uncheck JDK and Paste the copied path again in that and after OpenJDK add \
like this : Before : C:\Program Files\Unity\Hub\Editor\2020.1.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
After : C:\Program Files\Unity\Hub\Editor\2020.1.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\
If that doesn't works than uncheck JDK,SDK,NDK,Gradle and Stop Gradle (all five boxes) than close unity. Open Again and Check all five boxes again.
I don't know why, but on mac os unity may use latest version of java if you have one.
If you have installed a few versions of java, you can just remove all except java v1.8.
You can check which version of java you have by typing in terminal /usr/libexec/java_home -V.
You should have 2 or more versions.
If you installed them with brew, you can just use brew to uninstall extra java packages.
Also you can update JAVA_HOME system variable by type
echo export "JAVA_HOME=$(/usr/libexec/java_home -v 1.8)" >> ~/.zshrc.
This solution worked for me.

Android Studio Keyboard shortcut control

Can anyone give me some suggestion or link of all controls of Android Studio keyboard shortcuts?
Move to File -> Settings -> Keymap and change Keymaps settings to eclipse so that you can use the short cut keys like in eclipse.
Preferences > Keymap will show you all the keyboard bindings.
A couple helpful hints to help you find features:
You can search actions by name; on MacOS the keybinding is Command+Shift+A. You can start typing the name of a command and it will show you all matching commands and their key bindings if they have one. That's really convenient for looking up the key shortcut for something if you have a hint of what it's called.
In most dialogs/windows there's a search box, and you can usually just start typing to start a search. It's especially good for preferences, where there are so many options that are hard to find.
I may be late to answer this, but would like to help all others who come up to this page from now.
Here is the list of all the most productive shortcuts that I have been using regularly in my day to day Android development. It saves a lot of time, seriously.
Find only classes - CMD + o
Find files - CMD + Shift+ o
Find everything - Double Shift
Find symbol - CMD + Alt+ o
Find in page - CMD + f
Find usages - fn + Alt+ f7
Generate boilerplate code - CMD + j
Quick fix - Alt + Enter
Code completion - Ctrl + Space
Definition of a class or method - Alt + Space
Navigate to a class or method - CMD + Left Click
Refactor rename - fn + Shift+ f6
Run app - Ctrl + R
Format code - Alt + CMD+ L
Show documentation - fn + f1
Mode code up/down - Shift + CMD+ up/down
Generate Code - CMD + N
Recently opened files - CMD + e
Recently edited files - CMD + Shift+ e
Delete lines at one go - CMD + Delete
Add single line comment - CMD + /
Add block comment - CMD + Alt+ /
On the Mac OS go to Android Studio -> Preferences -> Keymap
to assign a keyboard shortcut, you need to navigate to
file --> setting --> keymap --> search and than right click and add keyboard shortcut --> in first stroke
you can add/change like
ex:
you want to assign Cntl + w than use Cntl with w
Android Studio > Preferences > Keymap > Select Your Option.
Default is: IntelliJ IDEA Classic
After Android Studio updating, you sometimes need to do that. For example, I updated Android Studio 4.2.1 and I did this because it turned automatically default Keymap which is IntelliJ IDEA Classic. I prefer to use MacOS.
Go to Help and select Default Keymap Reference will point you to one of these default keyboard shortcuts for Android Studio. It has all the keyboard shortcuts you can do in Android Studio. It's says for it's IntelliJIDEA but Android Studio is based off IntelliJIDEA, so all the keyboard shortcuts listed there apply in Android Studio.
Windows and Linux
Mac
Here is the official list of the shortcuts of Android Studio for Windows, Linux and Mac:
https://developer.android.com/studio/intro/keyboard-shortcuts.html#configure_custom_keymaps
if you have a favourite plugin that doesn't have a shortcut, just navigate to
Settings > KeyMap > Double click Plugins > Select desired plugin > Add
Keyboard Shortcut :: Then press down the hot keys you want to assign for the
plugin and click OK.
PS. be careful not to override any important AS shortcut.

Issue Displaying Japanese Characters in Eclipse

My ecliplse IDE is displaying junk characters instead of the correct japanese characters...
Tried many strategies , my encoding is set to UTF-8...but still no outcome.
Screenshots for references are attached..
Any help will be accepted...
Thanks in advance.
Open this file in your Workspace directory: <your_workspace_dir>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.ide.prefs
Append this line to that file: IDE_ENCODINGS_PREFERENCE=EUC-JP'Shift_JIS'
Restart Eclipse
Open Setting: Window > Preferences > General > Workspace > Text File
Encoding. In Other: select "EUC-JP" in dropdown.
Ok -> re-open that file;
The xml file might be saved as SJIS(MS932).
Maybe this page can help you:
http://internetmarketingcoding.com/how-to-convert-japanese-shift-jis-text-to-utf-8
Open the eclipse.ini config file in the eclipse home folder
Add the new parameter -Dfile.encoding=SJIS
Close and Open the eclipse.

Android Virtual Device location error

I'm having a problem with starting an AVD from Eclipse.
When I start the AVD that I just created, it gives me the following error:
I think that is because of the username in the path...
I tried to just copy the .android to C:\ (=C:\.android) but the manager is just searching in the old path...
I tried to setup a environement variable like this:
Name: ANDROID_SDK_HOME
Value: C:\Users\André Peixoto\.android\.android
But it didn't solve the problem...
What should I try next?
UPDATE
I reinstalled the android sdk and now it doesn't show the weird characters:
But the path for the AVD_2_3_3.ini file still wrong. I think it should be: C:\Users\André Peixoto\.android\avd\AVD_2_3_3.ini instead of C:\Users\André Peixoto\.android\.android\.android/avd/AVD_2_3_3.ini
How should I change that?
I solved that using the solution presented on the comment 26 from here:
No matter your configuration. If the message will be like this
"[2011-11-21 22:31:24 - Emulator] PANIC: Could not open AVD config file: C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd/config.ini"
(
"C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd"
- it's your AVD device configuration. )
than :
copy direcoty "my_defult_android_2_3_3_avd.avd" to some place where the path will not contain "Ярослав" symbols (I in result had
the path like this
"d:\android\my_avd_devices\avd\my_defult_android_2_3_3_avd.avd").
File "my_defult_android_2_3_3_avd.ini" will contained in directory "C:\Users\Ярослав.android\avd\". Open this file.
Change "path=C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd" to
"path=d:\android\my_avd_devices\avd\my_defult_android_2_3_3_avd.avd"
Save and close. Start your application again))).
But at the first time I tried this solution and it didn't work. So I uninstalled the android SDK and eclipse and reinstalled all over again. I also removed the environments variables for android_sdk that I had previously set and set a new one called ANDROID_HOME with value C:\android-sdk.
Now I'm able to run AVD.
I think this is not a ideal solution because each time I create an AVD, I need to do this process. But for now it solves my problem.
Hope this solution helps someone else.
UPDATE - New Solution
I was having some problems with the previous solution so I used a diferent approach:
I created a new account (Administrator) in my Windows which the username havn't accents.
I put my Eclipse folder inside C:\ to have access from the new account.
Now, when I want to work with Android, I change to this new account.

Problem with emulator in ANdroid

invalid command-line parameter: ..\Documents\android-sdk-windows\tools/emulator-arm.exe.
Any idea how can I solve that problem?
The only problem here is : you have to remove 1 extra space from the Eclipse path where you have declared your Android SDK from your local path.
This u can verify by following steps :
1. Eclipse->Windows->Preferences->Select Android option from left column.
2. See the path : in my case its : D:\Andriod SDK\android-sdk-windows
3. If u observe, there is a space in Android & SDK.
4. Close eclipse and go to the actual D location.
5. Change the name of the Android SDK folder to AndroidSDK. (Just remove the space in betn).
6. Restart the eclipse again and define the new path.
BINGO... Your emulator will run without any problem.
Thanks
Saurabh M. Chande

Categories

Resources