Android studio only finding "some" classes when browsing SDK sources - java

I seem to be having a massive problem with paths when browsing the SDK sources. Basically my issue is this:
I can import (for example) android.annotation.NonNull into my own project and it recognises the class fine. But if I open Activity.java I get random classes not being able to be found - but they exist in the correct path. For example it can find android.os.PersistableBundle (which exists at androidSDK\sources\android-23\android\os\PersistableBundle.java), but not android.annotation.NonNull (which exists at androidSDK\sources\android-23\android\annotation\NonNull.java)
I have tried invalidating caches and restarting, re-installing android studio, installing different versions and even redownloading the whole SDK, but nothing is making it happy. Is there a place I should be setting the 'root' path? How come it finds some classes but not others?

Android 1.2 or idea 14 do not have this problem. After this version have this problem.
You can view thie SDK source by use the Android 1.2. Click here to download. Unfortunately, Android 1.2 version has some other bug.

Related

Unity3D: APK file missing

Every time I try and build my game, I am unable to find the APK file anywhere, I did however found the APK file in my recent folder, but it doesn't show up in the respective folders I initially selected or allows me to copy and paste the APK file into my Android device.
I don't even get any errors when the game is built (in fact, I get a message in my console stating that my build was successful) so I am confused to why my APK file is not showing up.
It happened after I recently updated my unity 5.6 to unity 2018.3.1 due to Oracle JDK is no longer free for commercial use and unity 2018.3 uses OpenJDK (I am using AdoptOpenJDK/JDK-12.0.1.12-hotspot). Once unity was installed, I didn't receive any errors only a few warnings within a few scripts (which was only a minor problem and I could solve easily).
However, when I go to player settings, I get this one warning: "failed to get available Android API levels. Make sure your Android SDK tools version is 25 or higher and you have an internet connection."
I made sure that my minimum API level is Android 8.0 'Oreo' (API level 26) and the target API level is Android 8.1 'Oreo' (API level 27), I also uninstall Android studio and reinstalled.
I even went as far as deleting all folders inside build tools and platforms from (appdata>local>android>sdk>buildtools) & (appdata>local>android>sdk>platforms) and updating the files for continuing the build.
However, all the methods I've tried have not to work, so I'm asking for help here. Please, does anyone know why is my APK file not appearing at all? Thank you in advance, I really appreciate it! :)
this solution helped me if Are you using the r22 of android SDK, if so, Google decided to move the aapt.exe from tools directory to build-tools//aapt.exe
A quick solution for this is co copy the aapt.exe file from build-tools and paste as shortcut on tools directory. Keep the shortcut name as aapt.exe
another solution is to download jdk(1.8 version is prefered)from oracle site ["http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"]and set it instead of the build-in jdk form the project preferences then reboot

Cannot resolve symbol "Override" on "Hello_World"

I installed Android Studio the other day to develop an app and even though it's not the first time I've used it, it's the first time I've installed it on this PC and I'm fairly new to all of it.
Problem: After installing Android Studio, I can't even make a "Hello_World" app, even the templates AS offers have a compiling error:
Where it doesn't recognize symbols like "Override". The Alt+Enter solution that offers is to Setup JDK which does nothing for all options or create annotation 'Override' which doesn't really seem like a good option.
These are both build.gradle files:
Things I've tried to fix it:
Reinstall Android Studio Multiple Times
Download JDK manually and change references.
Check Enviromental Values on system (Add JAVA_HOME and heck Path to be correct). Pretty sure both java and JDK work since in cmd I can run java and javac.
Obviously Build->Clean and File->Invalidate Cache + Restart
android.enableAapt2=false on gradle.properties
Trying to delete all java from my PC and reinstall bare minimum THEN install everything separatedly.
Install all SDK plataforms until Android KitKat.
It's worth noticing that in the past I had a lot of problems getting java to run in only one place (mainly because I install software in an HDD and have OS on another SDD).
Also, while installing AS for the first time I got into a BSOD because of VT-x having shitty interaction with virtualization of anti-virus (that took me a while to figure out) so it stopped halfway. However I've reinstalled a bunch of times so I don't know how that could matter.
The problem is very similar to this one
I'm practically lost here. I've been trying to fix this for three days and I've looked into dozens of Stack-Overflow posts with similar problems, haven't found a solution.
Any idea will be appreciated.
Thanks.
I repeated your error:
I made it by deleting Android SDK(not java SDK) in Android Studio:
File-Settings-AndroidSDK
Try to pick at least one and install
It seems that your problem is related to Android SDK
Okay guys, I've finally figured it out, thanks to artmmslv.
Android Studio's installer detected automatically - two versions of Android SDK which were corrupted (probably caused by BSOD messing up the installation).
I had to make sure to delete everything. Java SDK, Android SDK. Java JRE. Every data from Appdata or documents from Android Studio. Once the computer is clean from any traces of already installed plugins, modules, and whatnot, it should be able to set up perfectly fine paths.
Also, make sure to set up manually and correctly the Environmental Values of java (path edit and JAVA_HOME).
Thanks for the help.
I got a solution that was a problem for me.
(in Build.Gradle file) - It's the
Compile SDK version 32
//which was not the latest one,
I changed it from older (31) in old projects to (32)
And clicked: sync now,
it worked!!
Hope it helps:) Happy coding

Android Project with ActionBarSherlock doesn't get built

I implemented the current version of ActionBarSherlock to my Android Project.
Everything works fine and I don't get any errors.
But when I try to debug or export my project I don't get an .apk-file out of my project. Just a .jar-file with the name of my project.
I've read about some problems the SDK had with building projects that contain external libraries but this was at SDK version 14 and so I hope, this bug is fixed...
So there might be another cause for this problem.
Does anybody know a possible solution?
You cannot get *.jar file as the result of building Android project. This seems very strange to me. There must be something wrong with your project settings (if you changed them), or the project you build is of the wrong type (i.e. it is Java Application instead of Android Application).
You didn't mention which IDE do you use, but I assume you use Eclipse.
Make sure you have installed Android SDK and Eclipse ADT correctly (just in case).
Next thing to try is to create a new Android Application project from existing sources (there should be such option during the process of creation).

Error when building apk - "Multiple dex files define Lcom/google/ads/Ad"

I've been tearing my hair out over this one, for the past 3 hours I've been trying to fix it but have been unable to. I've created an android app and I'm ready to put it on the android market but I get this error when trying to export to an apk.
Unable to execute dex: Multiple dex files define Lcom/google/ads/Ad;
I've read a bunch on the problem and tried quite a few solutions but nothing has seemed to help. I've cleaned and rebuilt, I've delete the bin folder, I've made sure that the bin folder is excluded build path. Nothing's worked. If anyone could help me I would really appreciate it.
Untick the admob jar file in the "order and export" part of the "configure build path".
On another post with a problem similar to yours the only thing mentioned that you have not already considered was updating Eclipse. I don't know how or what order that you have done these "fixes" but another poster mentioned that all at once he deleted the bin directory for his project, cleaned and rebuilt the project and restarted Eclipse. After that the error disappeared.
Good Luck- Lijap
For me the error was due to 2 different versions of AdMob SDK being included accidentally.
Removing one of them fixed it.
As other have noted, this problem should be due to multiple versions of Goodle's ad SDK classes being included in the app build. What I haven't seen yet is a note that the most recent Google Play Service lib includes classes that (at least) share the same names as some in the admob sdk-- for example, I came upon this error because I was trying to build with both admob sdk v.4.0.4 and the google-play-services_lib project as a referenced project; the latter contains google-play-services.jar which contains the package com.google.ads and many of the same classes as the admob sdk. Thus it appears that the google play services lib and the admob sdk cannot both be used in a given app. My solution was to remove the admob sdk entirely from the build.
I had the same or a similar problem. My problem was that my application imported a library which used a different version of AdMob SDK.
Details of my problem:
Library used AdMob SDK 6.3.0
Application used AdMob SDK 6.1.0
Fixed it by including the same version.
For me, I just have to take out the libs folder which contains android-support-v4.jar from build path and it worked.

Attach Android SDK sources in Eclipse

I want to see Android SDK source code in order to understand how it works.
How can I attach Android SDK sources in eclipse?
For newer releases
This is the only way to do it for the newer releases of the SDK:
http://source.android.com/source/downloading.html
It can take a little bit, but once you get it set up, it is easy to repeat for later releases. You will notice too that it helps solve the problem of the autocomplete lagging in Eclipse as well! Well worth it in and of itself...
For older releases
You need to download some source files specific to which Android API version you are working with.
The URL is
https://android.googlesource.com/platform/frameworks/base/+archive/<API version>.tar.gz
And you have to replace with one of these:
gingerbread-release for API 9 – Android 2.3
froyo-release for API 8 – Android 2.2
eclair-release for API 7 – Android 2.1
donut-release for API 6 – Android 1.6
so the URL becomes for example:
https://android.googlesource.com/platform/frameworks/base/+archive/froyo-release.tar.gz
for froyo, or:
https://android.googlesource.com/platform/frameworks/base/+archive/gingerbread-release.tar.gz
How to fix the autocomplete lagging problem once and for all
After you have downloaded the file, (which comes as .tar.gz by the way), you have to open the archive, and copy the contents of the base directory, into your
<android-SDK>\platforms\android-<API version>\sources
directory. (Create the sources directory if it does not exist)
When you now start Eclipse, you should have autocompletion working fine again!
There is even an Eclipse plugin for that - Android Sources.
However I just downloaded the plugin jar (~200 MB) and extracted sources from it. Then in Eclipse I attached the sources by going to my Android project, selecting android.jar > Properties > Java Source Attachment > External Folder.
In case somebody still needs that crusty old Gingerbread framework code, it can still be found in the depths of the Android source tree:
https://android.googlesource.com/platform/frameworks/base/+archive/gingerbread/core/java.tar.gz

Categories

Resources