I am new to Android development, and was wondering why a library like AudioManager (android.media.AudioManager) can be used, but when I try to navigate to the code of AudioManager, half the source code is red.
For example, it says,
cannot resolve symbol SystemService"
Do I need to add some kind of dependency somewhere?
This means that when I debug through AudioManager, the bytecode does not match what appears on the screen and the debug is useless.
I've tried looking at other posts and changing my SDK version to 27 and my minimum version up to 23.
Thanks in advance.
This seems to be an IDE error, typically when I am getting build errors caused by this, Invalidate Caches and Restart will fix this. You can find it by searching in the help menu or under File in Android Studio
You could try below points as it worked-out for it :
Exit Android Studio
Back up your project
Delete all the .iml files and the .idea folder
Relaunch Android Studio and reimport your project
By the way, the error messages you see in the Project Structure dialog are bogus for the most part.
try to update your Android studio, they always working for something like this. I recommend AS 3.3
Thanks to all for trying to answer. I found the answer to my question here: The import android.os.ServiceManager cannot be resolved.
Explanation:
Apparently the reason AudioManager had so many reds is because it depends on many "hidden" classes, that are purposely excluded from the .jar libraries. The #hide in https://github.com/commaai/android_frameworks_base/blob/master/media/java/android/media/IAudioService.aidl is one example.
I added Google play services to my project for maps but now keep getting this error "java.exe" exited with code 2.
I am not sure if it is different from "java.exe" exited with code 1 but I have tried all the suggestions online
My heap size is 1G. My target version is 21, I have clean rebuild etc..
When I click on the error it takes me to this CompileToDalvik.
How can I resolve this? Even if I remove google play services I still get this error( clean / refresh rebuild etc..)
We had similar issues and nailed it down to our app going over 64k (65,536) methods limit which could be what's happening when you reference google play services.
Enabling multidex resolved our issue so may be worth trying.
Google Multi-Dex Reference:
http://developer.android.com/tools/building/multidex.html
Using Visual Studio and Xamarin I got this error because I had a wrong path for the Keystore in the .csproj file, and for some reason this path did not get updated while changing the path for the Keystore in the Visual Studio GUI.
Manual correcting the path in the .csproj file solved it for me.
None of the others answers worked for me. What worked for me (but I don't know why) was to empty my bin and obj directories before doing a rebuild.
I've seen this error recently. It was caused by an invalid (layout) xml file. Unfortunately, you don't get more hints where exactly the problem is :( I'd try to exclude the xml files one by one and check if the build succeeds without a certain file. Good luck!
Edit : I'm not even sure it actually was a layout xml file, maybe it has been a style or color xml :/ Any recent changes to one of those?
Increasing the Java Heap Size to 1G is worked for me!
Clean the Bin and the Obj folders, and rebuild again.
If it doesn't work please check different JDK version.
I had this error when switching from VS Mac to VS Windows.
Here the topic Switching From VS Mac To VS Windows got “java.exe” exited with code 2
The issue was comming from the Android.csproj and the Keystore Path.
It was set to my Mac Path even if I had already changed it on
VSWindows AndroidProject => Properties => Signin
So I removed this lines on Android.csproj (edited with third text editor):
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>YourMacPath/Alias.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>Password</AndroidSigningStorePass>
<AndroidSigningKeyAlias>Alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>AliasPassword</AndroidSigningKeyPass>
On debug & release Part.
Then you can edit them on VS Windows.
Hope I helped someone.
See ya
Now in VS 2022, I had the very same problem and nothing would work. I had noticed that, at least in my case, problem started when I accidentally lost the certificate from the keystore. For debugging mode I just took the signature out since it provides it's own. However, I will need to re-add the key once I change to release. Once the proper key is found in the keystore, the problem is resolved. Apparently that error code is useless.
I am getting this error when loading my workspace in eclipse.
An error has occurred.See the log file
D:\XXX\App_name\.metadata\.log.
I can able to open other workspaces and also able to create new onw.I didnt save the copy of my code.Please anyone help me?
Thanks!!!
Thanks for all who commented for my question.I tried your answers but I can resolve that issue by removing this folder from my .plugin folder,
.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi.
Thanks
Try typing the following in the console:
C:\path\to\eclipse\eclipse -clean
I faced similar problem while running Eclipse neon with Java 9(latest). I used to get error in .metadata.log . Class not found exception.
Checked in eclipse forum and they had a know error with Java 9. Work around was to use java 8. I tried that and it worked for me. Fix should be out anytime soon.
There are other work around but i did not need it since my project required java 8 anyhow.
When you try to add plugins via Eclipse IDE (Help->install new software) the problem occurs.
I suggest you to get the relevant plugin using there official website or in IDE (Help ->Eclipse market place).
I got this error when code my Android app:
I do nothing to this strings.xml file.
Can anyone fix this error?
I do refresh and clean but nothing change.
Thanks.
As per your Comment. Here i post my answer. For this problem. Try below steps -
First just remove the project from your workspace.
And, after just import that project again into your work-space.
Sometimes, it happened for me. I tried to do this way. It works.
Hope this helps you.
Most Often this happens to me too.
Try to remove project from workspace and re-import it.
Hope it will work :)
It seems you have used localization is your app.
There are different possibilities for the error to occur:
1)You have not localized all of the strings.
2)Other problems are persisting and you are not ignoring them.
Solution:
Right Click on your project----> Java Compiler-----> Errors/Warning---> Remove all errors
let me know if this works.
What version of the SDK are you compiling against? According to this list, you need at least Android 2.3 for Vietnamese localisation.
Encounter this problem when trying to Build Project getting such output in console:
[2010-07-19 23:29:23 - myProject]
trouble processing "javax/net/SocketFactory.class":
[2010-07-19 23:29:23 - myProject]
Attempt to include a core VM class in something other than a core library.
It is likely that you have attempted to include the core library from a desktop
virtual machine into an application, which will most assuredly not work. If
you really intend to build a core library -- which is only appropriate as
part of creating a full virtual machine binary, as opposed to compiling an
application -- then use the "--core-library" option to suppress this error
message. If you go ahead and use "--core-library" but are in fact building
an application, then please be aware that your build will still fail at some
point; you will simply be denied the pleasure of reading this helpful error
message.
[2010-07-19 23:29:23 - myProject] 1 error; aborting
[2010-07-19 23:29:23 - myProject] Conversion to Dalvik format failed with error 1
I was looking for my project to use the package javax, not found, clean all also does not help. what I am doing wrong?
Update
Sorry guys, but I could not find good fix for that, I want to emphasize the fact, that i dont use SocketFactory class in my project at all! source code was not changed before this problem, and that's why i think that problem in eclipse or adt or something else, BUT if i use ant(generated by sdk) to build this project there is no problem!!!
I solve this problem by removing Eclipse, Android SDK, Eclipse workspace, and just reinstall them, after this all works fine for now.
Hope this will help someone.
I had the same problem..
This worked for me
project-->properties->java build path->libraries-> remove all including android jars
now go the project browser, right click on the project you are working on,
then android tools---> fix project properties...
do a clean and then build...
I solved the problem (at least for me).
Here's what I did:
Go to Project » Properties » Java Build Path » Libraries
Remove all except the "Android X.Y" click OK.
Go to Project » Clean » Clean projects selected below » select your project and click OK.
That did the trick for me.
Hope it works for you as well
Update: well actually I might have to retract my opinion.. the actions removed the error messages but now I am missing certain classes and methods... arggghhhh
I just restarted Eclipse, and the error didn't appear anymore!
I had the same problem,and solved it as follows:
First clean all jars; (This problem must because your some jars)
Delete the project;
Reimport project;
Make sure your sdk is right, and project select one sdk version;
(This is my issue to solve the problem) Right click your project, and select "build-path", next select "add Librarys", and add your private jars;
clean-build, the problem has fixed;
I just had the same problem and I tried all of the solutions listed here with no success (I was starting to get annoyed). Then I removed the project from the workspace and then imported it again, and there were no problems!
This happened to me this way,
I have a quite an old project which I had to start working again today. I use 'Universal Image Downloader' library for basically every project where I have to deal with lots of images. So in this old project I had the source files of 'Universal Image Downloader' included to it's 'src' path. Back then I was a newbie and slowly I started developing my own library which could handle every day simple Android development tasks very easily. Obviously I included the 'Universal Image Downloader' to this.
After dusting off the old project today the first thing I did was to reference my library to speed up the development process but as I was trying to debug I ran into the "Conversion to Dalvik format failed with error 1" over and over again. First I thought it was the support library but even after clearing all libraries and adding only mine and doing a quick 'Fix project properties' I still got it. After trying various solutions I noticed this in the console "java.lang.IllegalArgumentException: already added: Lcom/nostra13/universalimageloader/cache/disc/BaseDiscCache;"
It was as simple as that... I'm trying to compile a class which has already been compiled.
Solution : I just simply removed all the class files I got from 'Universal Image Downloader' library from the 'src' directory. Since my library references "Universal Image Downloader" library the old project started working just fine.
Hit same problem shown on your log when trying to run an example project which was imported into eclipse.
Additional Info: in eclipse's Problems View I see the following error:
"The project cannot be built until build path errors are resolved"
In my case the imported project find the libraries just right(by just right I mean I can see the external path to each of the android libs in this case 2 libs, android.jar and maps.jar). So no shuffling of libs in my case, but might be your problem.
I followed Spock's suggestion of cleaning the project which I had to clean multiple times until it somehow resolve its issues. After, issue was solved I had to specify an AVD for the project to run and soon after was up and running on the emulator. Also, note that my eclipse is set up to Build Automatically.
In my case I'm not missing any class files or anything after the clean as the build is properly generating them.
Regards!
I was getting the same error. My problem was that i had an android device hooked up to debug with. As soon as I unplugged it I was able to export.
The answer I found was checking the source and library build path in the project's properties. Most likely there will be a duplicate as in something being referenced in both the source and library tabs. So delete the extra in the source tab and then clean the project and you should be good to go.
Either:
javax.net.SocketLibrary is in your source code, or
javax.net.SocketLibrary is included in a JAR file in your project
Under certain conditions it gets its knickers in a twist and the best fix I've found is to remove referenced jars, clean, add them back in and then compile again.
I believe the error can be caused by including the same classes twice.
This error will also occur (and you won't be able to get rid of it by cleaning) when using classes that are not part of the Android environment.
To summarise the information in the link bimbim.in provided (well my understanding when I glanced over it)
The Android Davik VM tries to compile the jars but finds some stuff that it can't compile to .dex files
so
Just create a "lib" directory in the root of the project (where the src, bin res directories are) and add them to the build path. Project Properties... Java Build Path... Libraries.. Add JARs..
I could resolve this issue by creating a new project, looks like the some project settings were creating this issue and could not really find the root cause for that. But, dumping the existing source code onto the new project resovled this issue. If anyone has found the root cause for this problem pls do let me know.
I had the same problem and solved it as follows:
- Go to Project/Properties/Java Build Path/Libraries and remove all JARs except Android
- Do a project clean
- Add the JARs again as External JARs (first time I added them internally, so that might be the problem)
After that the error was gone.
I solved the problem by updating available packages in the Android SDK et AVD manager. No need to remove Eclipse.
Whenever the Project is having the ambitious data. This problem is caused. May be android can't able to find which one choose.
From what I understand, this same cryptic error could be caused from a wide variety of reasons. I've got "Conversion to Dalvik format failed with error 1" error too. In my case the problem was that for some reason Project -> Properties -> Java Compiler was not set to "Enable project specific settings" with proper Java 1.5 settings, but was left to defaults instead (1.6 in my case). Debug, build and test on devices/emulators worked fine, but export always failed with the above error message.
If unsure about the proper settings, create the same project on some alternative location and just copy all needed files from the old project into the new one. This fixed the issue for me.
The next problem with the same error message came from using proguard. Updating to the latest version by replacing the one that came with android sdk, fixed that.
Hope this helps
My problem was having a jar file in my src folder. Removing jars from the build path works, but only if you don't need the jar in question. For people who need the jar in question, make sure that your jar file is not in the project folder (maybe just src subtree, but I would keep it separate to test). Put it on your desktop or something and try the "Add external jar.." option. Be sure to remove the jar from the project filesystem before adding another external. Having both is what causes the problem.
I have done it as the instruction of the first answer and it works.(Linux)
I think the problem may caused by SDK or ADT updates.
I do have to clear all the lib in Java Building path and then use android tools to fix the project. After cleaning and rebuild, it works as before.