Android Studio uses wrong different SDK version for different classes - android

I faced a problem when Android Studio started marking code in red:
When I click to view source of findViewById() it takes me to sources of Android SDK 16 which is different from my project's compile SDK version (29).
At the same time in some other classes within the same project there is no such problem and findViewById works well. Clicking on it brings me to Android SDK 29 sources which is correct.
My project has compile SDK version set to 29, it's dependencies use compile sdk from 16 to 25.
I already tried:
Clean project.
Rebuild project.
Invalidate Caches / Restart
Reinstalling Android Studio and installing Beta version.
Tried to use different GIT commits where no such problem existed.
Deleted /.idea and /.gradle folders.
When I delete sources of Android SDK from ~/Library/Android/sdk/platforms/android-16 it helps until next rebuild (then Studio automatically downloads it again)
What started the problem: to fix GIT history I removed all files from working directory and copy-pasted a new version there. Not an elegant solution, I know, but there were no problems in git difference. The thing is that this "red code" problem now exists in all previous commits.
Project compiles without errors and application can be installed!
Please help!
Update: this problem arrises only in Fragments! Somehow getView() in Fragment give me a different version of view?

Solution found:
update implementation 'com.google.android.material:material:1.1.0' to version 1.1.0. Don't now why this dependency started creating problems.

Related

Android databinding generated files disappears when coding

I am facing a strange problem when Fragment*Binding files are deleted while I am writing code (all references become unresolved, generated files absent in files system) that can be fixed by clean project-> make the project but it is time-consuming.
Such behavior occurs 3-4 times per hour.
Originally I thought I might be deleted by antivirus software, but I checked that all paths related to development are in Av exceptions.
Android studio bumblebee latest updates (happened few updates before too)
I had the same problem and it was because of gradle, for a while i changed the gradle version (lower or higher should be tested) (requires invalidate cache and restart), then worked with that gradle for a while then changed it back and it was fixes
First make sure that the dependencies you are using are updated to their latest version also your Gradle and Gradle Plugin are latest and compatible with each other.
Also check if you are using the latest Android Studio Bumblebee version which is
2021.1.1 Patch 2 Built on 17 Feb
Shortcut for clean or rebuild project :
Press Shift Key twice and then search 'clean' or 'rebuild' and press Enter

Can't compile Unity Project with ARCore SDK - Problem with Gradle

I am trying to solve this problem for a few days now. Whenever I import ARCore SDK, to Unity, I cannot compile my project.
The error I am facing now is:
Minimum supported Gradle version is 5.6.4. Current Version is 5.1.1. If using the gradle wrapper, try editing the distributionUrl.
I did so, I saw in my eyes a new version is imported but I am keep getting this error.
Here are some other things I tried:
Trying to import the SDK to multiple versions of Unity.
Using a different computer.
Not changing the minimum API Level to 24.
Building the app without scenes.
trying to use different Gradle versions besides 5.6.4. In particular, 6.7, 6.1.1
Creating a system variable under Path: C:\Gradle\gradle-6.7\bin
Removing 5.1.1 folder from the Temp folder of the project, whenever I compile it (Although it keeps appearing of course)
Following the guide found at:
https://developers.google.com/ar/develop/unity/quickstart-android
Ensuring JDK, JVM and all required components are installed.
All to no avail. The project is not compiling.
Any help would be greatly appreciated!
EDIT:
I believe the root of the problem is that I haven't changed the Gradle version somewhere, despite doing so at the wrapper. The reason I stuck at 5.1.1 has something to do with the default Gradle version of my Unity version.
https://docs.unity3d.com/Manual/android-gradle-overview.html
Question is, how to solve it.
I can think about two ways to solve it (but they are pretty similar):
First Option:
Download the gradle version you want, navigate to where Unity's gradle is located in:
C:/{UnityEditorsDirectory}/{UnityVersionDirectory}/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/gradle
Then replace lib folder with your new gradle lib folder.
Second Option:
In case this doesn't work, you can also try to:
Open Unity Editor, go to the menu tab Edit->Preferences->External Tools
Scroll down and find this toggle:
If you uncheck the toggle, the editor will allow you to browse where your gradle is located, paste your new directory and try if it works.
TAKE CARE: Unity's gradle version is the one that Unity's people have tested so...something can explode unexpectedly!

Android studio IDE shows unresolved references / ignores imports, while builds are fine

Since couple of days I have problems with my android studio IDE, quite desperate at the moment. Various library imports are not recognized any more (some are, some not, junit e.g. isn´t), showing me unresolved reference error and autocompletion isn´t working as a consequence. But it´s only the IDE, gradle builds are fine.
Gradle files should be fine, the pic is from a new project where everything is set up properly. Same problem with old and new projects. I tried like everything already:
Deleting .idea folder + .iml files and reimporting the project
Invalidate Caches / Restart...
Deleting .android/cache
Deleting HOME/.gradle/caches
Downloaded and installed new Android Studio (v3.2.1), opened old, started new projects
Switched kotlin plugin versions, compilesdk versions, android gradle plugin versions, kotlin versions, gradle versions
I did couple of updates at the same time, Android Studio to 3.2.1, Kotlin plugin to 1.3.0, android gradle plugin to 3.2.1, installed newest sdk 28, switched from gradle 4.6 to 4.10.2. Shortly before, I had another weird behavior, where opened files didn´t show the real content but instead cryptic, binary symbols for nearly all the gradle or source files. Only deleting whole project folder and recloning it from git solved that one. I blame a hard reset while studio was running for that. As if anything android studio related on my machine is messed up. But even new installation of studio does not help
Ok, finally solved the problem by completely removing all android studio installations (using the included uninstall.exe), deleting HOME/.android and all HOME/.AndroidStudiox.x folders, then reinstalling android studio (not finding anything from previous installations anymore). Could then even reimport my settings, exported previously

Android Studio 3.1 Stable. Build Successful but Can Not Resolve Error

I have updated to Android Studio 3.1 Stable Version today(27 March 2018).
I have an old project. With new studio version, it gets build successful and app gets installed on Emulator, but the on the IDE, Activity file shows
Can Not resolver Error
.
gradle file app module
Project level gradle file
I spent a long time on this yesterday after migrating from Android Studio 2.3 to 3.1. Tried everything from other answers to similar questions. Google's maven repository was correctly configured, tried invalidating caches and restarting, restarted the computer, etc.
The one thing that worked for me was closing Android Studio, deleting the .idea folder from my root folder and starting Android Studio again. Since I had everything checked into git before starting the upgrade I was able to do:
rm -rf .idea/
git checkout .idea
So I ended up with my original idea project files, but you should be fine if you can't revert to your checked in idea files. After reopening Android Studio it recreated some of the files I ended up deleting and everything worked again. Hope that helps others with the same problem.
This answer is old but basically suggests the same thing so I guess this problem keeps showing up. https://stackoverflow.com/a/21100896/791560
I was able to Fix:
https://developer.android.com/studio/build/dependencies.html#google-maven
From Android Studio 3.1, if we are working on Old projects built on 3.0 or lower, you need to add maven repository at top level build.gradle file. i.e., add google() under repositories of all projects.
For new projects, it gets added automatically.
App level, build tools version should be at min 27.0.3
Make sure compilesdk version and support library version are the same version level.

Updating to Android SDK Tools R22

I updated the SDK Tools to R22 and the ADT Plugin as well. Everything worked well before the update but since then, I have problems.
Basically I have 2 library projects and an app project. One of my library projects contains some jar files in the "libs" folder. One of these jars is used in the app project itself for some initial setup. Before the update, everything worked fine, but now it asks me to add the jar to the build path and even if I do so, when running the app it still gives me ClassNotFoundException.
Did anyone had some similar experience or has any idea about what causes this and how can it be fixed?
Thanks.
Check this Android Sdk tools Revision 22 issue?. "I found that I needed to check all of the boxes in the order/export tab of the Java Build Path for the project - and each library -- to properly compile and run the app on a device." - should helps.
The workaround here worked for me
OK. I also had a Simillar kind of Problem.
Like say If you have library project as google-play-services_lib before updating than might happen that your library code has been also updated after updating your SDK.
You Should Remove that library project from your Workspace and Import
again from the source
folder like in my case i had to import from /android-sdk-linux/extras/google/google_play_services/libproject/google-play-services_lib. Add reference of
your library path to you android app project. clean and build your Project.
Hope this Helps.
you should try to upgrade eclipse.
1) Get the new imports via the Android SDK Manager
2) Check for updates in the Eclipse repository: help/check for updates
That would "for real" upgrade the SDK version in your configs.
Dunno if the other steps pointed by VShcryabets are needed, i had them before.

Categories

Resources