Android studio can't find ArrayList class - java

First of all I've been using Android studio for quite years but this has never happened before.
It seems like android studio's inner ArrayList class has vanished out of a sudden. I can't use ArrayList. It always says Can't find symbol ArrayList
I've cleaned rebuild and even invalidated caches and restarted several times but all in vain.
package dev.moutamid.testapp;
import java.util.ArrayList; //<--- this gives error
public class FragmentDashboard extends Fragment {
private ArrayList<refUser> refUsersList = new ArrayList<>(); //<--- and this line
}
My android studio is up to date. I then opened a new project and tried to use ArrayList but it was still not showing. Feels like there's nothing related to ArrayList in studio.
Yesterday I got BSOD (Blue screen of death of Windows) and today it's happening. I'm using git repository to backup my project.
What could be the solution?
I think Git has deleted ArrayList class because it already had corrupted several files before. I got luck due to the backups.

Well this is really weird. Would suggest you to try the following:
Check the jdk in android studio and check the path. If you still facing this problem then install a fresh jdk which you download online and put in the new path and try.
If this is also not working, back up all files and reinstall Android studio. Uninstall the current copy and install a fresh one.
Well since you have had a Blue screen issue, would highly recommend to do a fresh install of windows. You haven't specified which Windows version you using so I am assuming you are using Windows 10.
This link should help you out for Windows 10 : https://support.microsoft.com/en-in/help/4000735/windows-10-reinstall
And please keep taking a backup of whatever you need regularly.

I am guessing whether this is possible:
On macOS, enter java -version in the console to check the currently installed Java version. For example, I output the following:
➜ ~ java -version java version "1.8.0_212" Java(TM) SE Runtime
Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM
(build 25.212-b10, mixed mode)
Check whether the JDK location in the SDK Location in Project Struture in Android Studio is correct. For example, my address is as follows:
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home
Or select app in Modules and set the Source/Target Compatibility of Properties to try?
I hope it helps you~

Related

How can I launch Image Asset Studio (Android SDK commandline tools) from the command line?

I am trying to run Image Asset Studio from the Android SDK and am encountering an error I cannot solve.
To give a little bit of background, I am presently limited by an ageing laptop (AMD A4-5000, 8 GB RAM, 1 TB hybrid disk [256 MB? SSD]) and, whilst I don't really have any major issue with Android Studio IDE, I find it very bloated and eats up my CPU time and memory. Visual Studio Code on the other hand, suits my cross-platform developing needs almost perfectly, is lightweight and with a plethora of extensions covering all I have needed thus far.
I am attempting to simply execute the Image Asset Studio .jar file from the command line and am encountering a Class Not Found error that suggests my paths might not be configured correctly, but as far as I can tell, all is well... all the other tools I have used have all worked as expected, but this is the first time I have tried to use one of the JAR applets from the /lib/ directory.
I have the latest (AFAIK) Android SDK command-line tools installed in my home directory, and I am trying to launch the Image Asset Studio from the command line. Two examples I have tried are:
~/android/tools/lib$ java asset-studio-26.0.0-dev.jar
~/$ java ./android/tools/lib/asset-studio-26.0.0-dev.jar
These give me the following error, or variations thereof:
Error: Could not find or load main class android.tools.lib.asset-studio-26.0.0-dev.jar
Error: Could not find or load main class asset-studio-26.0.0-dev.jar
Also, I have tried with the -jar flag:
~$ java -jar ~/android/tools/lib/asset-studio-26.0.0-dev.jar
no main manifest attribute, in /home/noscere/android/tools/lib/asset-studio-26.0.0-dev.jar
Different error, same effect :-)
I was previously getting a different error, which related to the wrong Java JRE being executed (I have 11 installed as well as the required 8 - solved with a quick sudo update-alternatives --config java). Here is my current Java version:
~/android$ java -version
openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-8u342-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)
For reference, sdkmanager --version gives an output of 7.0 - if that helps identify my SDK version.
Is it possible to be successful in running any of the SDK Java apps from outside of the Studio IDE? All the other command line tools (sdkmanager, avdmanager, adb, etc.) are all working seamlessly thus far. In fact, I've not encountered any issue with my Visual Studio Code + SDK command-line tools development environment (well, that hasn't quick-fixable), until now...
My environment variables relating to the Android SDK are as follows (and all correct):
export ANDROID_HOME=$HOME/android
export PATH=$ANDROID_HOME/cmdline-tools/tools/bin:$PATH
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export REPO_OS_OVERRIDE="Linux"
I'm stumped. Google-searching has thus far been fruitless. I'm loathe to install Android Studio IDE just for this, when I have successfully developed several apps over the years without needing it. I'm loathe to admit defeat.

I am not able to install Android studio after downloading it

I have downloaded and installed JDK tool in my programx86 for windows 32.
I have set JAVA_HOME AND JDK_HOME variables. I have also set path.
I checked in the command prompt if JDK is installed and it is showing me version 1.8
Then, I downloaded Android studio.zip for windows 32.
Unzipped it, and saved it in the programx86 folder.
Now, I am suppose to run studio.bat and get the android window. But, in actual, when I click on studio.bat, I just get a flash and then nothing happens.
I tried everything. Uninstalling/installing java again and again. Setting the java path. Changing the location of Android studio.
But, it is not working for me. I am not getting the android installed. Please someone help.
I have a error file in my recent files. When I opened it, it has long text but the main msg is "EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x33773dd4, pid=7404, tid=0x00003898
#
JRE version: OpenJDK Runtime Environment (8.0_152-b02) (build 1.8.0_152-release-1024-b02)
Java VM: OpenJDK Server VM (25.152-b02 mixed mode windows-x86 )"
If this gives you a clue.
try to run .bat as Administrator. or for easy simply download Android Studio and install.
I'm a little late to the party, but I was having the same issue as you and here's what fixed it for me: setting a system variable named STUDIO_JDK to the path of your JDK installation ("C:\Program Files\Java\jdk1.8.0_181" in my case) then run "studio.bat".
Looking inside the .bat it looks like Android Studio checks STUDIO_JDK before JAVA_HOME or JDK_HOME.
i also face same issue ,but i resolved it.
Please check your C drive have proper space or not if no than make some good space.
if done that please check your android studio will run .
or
remove older version from your device and it will automatically start working .
Thanks !

e(fx)clipse code completion isn't working

could you give me any advice how to fix that, please?
Recently I installed e(fx)clipse, but code completion when you type a dot, isn't working. Google didn't help.
Edit: Ctrl+Space works well, But dot with dropdown list of options is not working. (when you type a dot and see which methods can work with some instance)
Edit2: Also, when I type imports like:
import org.openqa.selenium.*; -----> autocompletion is not working here, even if I type that exactly under the line like that (in my old projects) - so it's not the issue of a project settings.
Installation details
Edit3: Content assist looks fine... but the issue still present.
Edit4: After doing this:
To clarify Alex's answer.
I had the same issue of being unable to get auto-complete with my JavaFX CSS. My fix was add the JavaFX SDK to the library list. To do that:
Go to Project | Properties
Select Java Build Path in the tree
Click on the Libraries tab
Click the Add Library... button
Choose JavaFX SDK
Click Next then Finish
Click Apply
Click OK
e(fx)clipse failed to start at all. (only splash screen appears for a milisecond)
Edit5: Java version is:
$ java -version
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) Client VM (build 25.71-b15, mixed mode, sharing)
Edit6: Funny, but after I reinstalled e(fx)clipse, it still fails to start. The same issue with 1-millisecond splash screen and nothing more..
Edit7: Reinstalled JDK + several times reinstalled e(fx)clipse: 2 times version 4.5.2 and one time the version 4.6RC4a - - - in all the cases just 1-millisecond splash screen appears and nothing more... yep, and before these reinstallations I cleaned Windows registry.
Edit8: I just used Java Mission Control and recorded timeframe during which I tried to open e(fx)clipse, and I noticed this thing:
From Java Mission Control
Thanks in advance.

Android Studio failed to load JVM on Mac OSX (Mavericks)

I am trying to setup Android Studio on my Mac. It is running OSX 10.9.1 Mavericks. I have installed the latest JDK (at the time of writing 1.7 update 45), and I installed Android Studio. I use Java 7 because I have some Java applications I have to run and they require 1.7. I have not installed Java 1.6, because it is ancient and old. Launching Android Studio from any launcher does literally nothing. Activity Manager never shows it running. I do not want to install Java 1.6.
I did some work and tried to run the executable via command line through the package contents, and for both executables, I get these messages:
I am unsure what I am supposed to do to fix this error. I'm not very adept on a Mac (still somewhat new to it, and its confusing to do power user stuff on this) so if anyone can help me figure it out that'd be great. I'm on the 2013 Macbook Air with plenty of resources for this to run.
Update: This also applies to Yosemite, El Capitan, and all the other versions of OSX that can run Android Studio.
Update 12/11/2014
As of Android Studio 1.0 RC3 you can follow this set of directions to make it work.
I figured it out. You have to edit the android studio's Info.plist file in the package so it uses 1.7. I don't get why Android Studio insists we install and use an outdated, vulnerable version of Java.
Full resolution: http://i.stack.imgur.com/yyYaG.png
To open the package you need to find the Android Studio.app file in the Applications folder and right click it > Show Package Contents.
Edit the plist (I think you might need to be root) and change JVMVersion from 1.6* to 1.7* (or 1.8*, or whatever JDK major version you have). I don't get why that made a difference since my original output said it was using 1.7 anyways.
This fix seems to apply to all of IntelliJ's IDEs (I've seen it on PyCharm as well), though other ones seem to support newer versions of java natively.
As answered by hasternet # Android Studio was unable to find a valid Jvm (Related to MAC OS)
For quick and dirty solution, Follow the answer by Mgamerz; open Android Studio in Finder (CTRL+Click > Show Package Contests > Contents > info.plist) and edit Key JVMOptions>JVMVersion from "1.6*" to "1.6+"
Recommended method as discovered by Antonio Jose is to edit environment variables in MacOS (messing with info.plist is not recommended)
either at program launch (opening the Studio through terminal rather than the icon)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app
or setting up the environment through AppleScript at every MacOS startup:
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
do shell script "launchctl setenv STUDIO_PROPERTIES /Users/username/Library/Preferences/AndroidStudio/idea.properties"
do shell script "launchctl setenv STUDIO_VM_OPTIONS /Users/username/Library/Preferences/AndroidStudio/studio.vmoptions"
(Remember to save the script as Application. Antonio Jose managed with just the first line - AFAIK you can use .properties and .vmoptions to set up additional settings.)
Official instructions: http://tools.android.com/tech-docs/configuration/osx-jdk
(The reason why Android Studio want's to run off of JRE 1.6 is because it apparently makes the fonts look better - feel free to go through that "official" route and install JRE 1.6 # http://support.apple.com/kb/DL1572 - you can then set the JDK to 1.8 in the SDK Location settings - local.properties)
mgamerz is right - The release notes give a much better solution for rc3 and onwards - theres a idea.properties file
(or environment variable)
~/Library/Preferences/AndroidStudio/idea.properties
it also shows what environment variables you can use to set things like the jdk
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
ref : http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released
I did below command on Mac Terminal to fix this problem, please make sure java version and path.
$java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app
Hey Friends I just Figured it out a simple way to fix this for Mac users.
Open Terminal and type this -> java -version and hit enter.
Output will be something like this:
Now check your Java Version. My Java version is 1.8
So now we need to Open Contents of our Android App.
For that right click the Android.app and then select Show Contents
Like this
Now there will be Content folder, Open that Folder and there you will find Info.plist
Open this info.plist
And you will see this.
In this expand the JVM
Here you will see the JVM version showing 1.6* but our jvm version is 1.8 (for example my jvm version is 1.8)
So we need to change this number according to our jvm version, so i changed it to version 1.8*
Then click save. And you are done.
Now you will see setup wizard running
And you are ready to start your first android programming app.
Here is the Whole Docx file for Android Studio Setup in Mac X
LINK: https://www.dropbox.com/s/9jwjebn5hgydyll/Android%20Studio%20Setup%20on%20Mac.docx?dl=0
I found that downloading an extra Java bundle from Apple fixed the issue.
If you search for this problem then I found the second link was to a blog having exactly this problem, all credit goes to him here
I know that posting links isn't an answer but as you can see from the resolution you need to make sure you have an up to date version of Java and also the Java bundle from Apple, for this reason I have also included the searches needed to get to these websites.
Here is where to download the latest version of Java
If this link is broken then searching "java latest version" return it at the top of the Google list
Here is where to download the Apple Bundle
If this link is broken then searching "Java for OS X 2014-001" returns it at the top of the Google list
For me trying to solve this problem it appears that initially it was an issue that required a work around and then Apple released an official work around download meaning that fiddling in plists is not necessary any more.

Android SDK installer stuck on "Detecting whether Java SDK is installed" [duplicate]

This question already has answers here:
Android SDK installation doesn't find JDK
(46 answers)
Closed 9 years ago.
Like the title suggests - the Android SDK r20.0.1 installer won't get past the "Detecting whether Java SDK is installed" (picture below).
I'm running Windows 7 64 bit.
My steps:
installed both 32 bit and 64 bit Java SDK;
I've set my Path (from My Computer>Properties) to "C:\Program Files (x86)\Java\jdk1.7.0_05\bin", the 64 bit version of that and without the \bin at the end AND \jdk1.7.0_05\jre\bin;
I've added the Java Development Kit key to Wow6432Node;
ran the installer as admin but still, it won't detect the darn thing.
Also, I can't click back OR next OR cancel. Nothing happens when I do, just like nothing happens when I click the X. It won't even shut if I right click and close it so I have to bring out the Task Manager every time to close it.
Note - I'm not extremely tech-savvy so a step-by-step guide to whatever you want me to do (if anything) would be appreciated.
Do detect whether JDK is installed and its path is properly configured or not do the following
First see whether a java folder has been created or not in the place where installed it.
If you want to check that whether its path has been configured properly, then do this..
Go to command prompt and type the following:
java -version
If you get the output something like the below, then you are good to go, else think you have not properly configured its path. And in the output the version number will be different than its here, depending up on your JDK version.
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
Try to click Back button and re-clicking the install button.
This worked for me.
I actually solved this problem recently by changing the slashes to backslashes.
So instead of C:\MyJavaInstall\Java use C:/MyJavaInstall/Java
I was surprised, but this was the only thing that worked for me.
The reccomended version for Windows is the JDK 1.6 32 bit, make sure that you have installed only this one as JDK and all the environmental path are set, especially JAVA_HOME.
Developing for Android on Windows is always discouraged.

Categories