I'm trying to follow this YouTube tutorial for Android Studio, but when I create my project, I get the following error:
class org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager cannot be cast to class org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager (org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader #1824eb4b; org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader #61548dd0)
class org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager cannot be cast to class org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager (org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader #1824eb4b; org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader #61548dd0)
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
AS: 2020.3.1 (renamed version from 4.3)
OS: Linux (Fedora)
Gradle: 6.8
At first, it seems very similar to this issue, but the first two lines of my error are different, likely because my AS version is much newer.
I am positive this has nothing to do with a network timeout.
I tried the solutions on the similar issue, deleting my Gradle wrapper from ~/.gradle/wrapper/dists and then re-syncing the project. While this removed the error, it failed to generate the app directory with the initial project files, and I was left with just the configuration files:
Thus, I'm either looking for a different solution to the dependency cache error, or a fix for the missing project files.
This issue seems to be specific to projects in AS 2020.3.1 that use Kotlin. I could not reproduce with Java projects or AS 4.1.2 (the version used in the tutorial).
Update: Deleting and reinstalling AS 2020.3.1 did not solve the problem, but replacing AS 2020.3.1 with AS 4.1.2 did. Furthermore, after replacing 2020.3.1 with 4.1.2 and then reinstalling 2020.3.1, the project then worked on 2020.3.1. This must be due to a configuration issue with 2020.3.1 that is fixed via the configuration settings of a previous version.
This is a hacky answer without much explanation, but after much hassle, the following solution resulted in a working project.
The problem appears to be caused by a configuration issue with 2020.3.1, and is solved by the automatic configuration that occurs upon opening a previous version of Android Studio.
Delete Android Studio (my install_dir is /usr/local):
rm -rf {install_dir}/android_studio
Download Android Studio 4.1.2 from the download archive
Install and run Android Studio 4.1.2
tar -xvzf android-studio-ide-201.7042882-linux.tar.gz
cd android-studio/bin
./studio.sh
NOTE: If AS fails to run, remove disabled_plugins.txt
Close Android Studio
Redownload (if necessary) AS 2020.3.1
Install and run AS 2020.3.1
tar -xvzf android-studio-2020.3.1.22-linux.tar.gz
cd android-studio/bin
./studio.sh
NOTE: Again here, if AS fails to run, remove disabled_plugins.txt
Create an Empty Activity Kotlin project, and there should be no issues
Related
I'm using Ubuntu 18.04
Android Studio Version 3.6.3
I think I have two installed Gradle locations If I'm not wrong
One of them installed using sdkman, when I use terminal to locate the Gradle
which gradle
Also, I've found (I don't remember if I installed Gradle in another way instead of sdkman) in my home directory, this is the one which Android Studio is using (I think) and make issues when opening a project
I think I need to use sdkman as it's easier to update the Gradle version etc.
So, my question is should I remove the gradle from: "/home/khaledomara/.gradle". If so, what is the best method to do that and what path should I put in the settings of Android studio?
Should it be "/home/khaledomara/.sdkman/candidates/gradle/current/bin/gradle"?
You only have one Gradle installed - the ~/.gradle directory is where a running Gradle process stores data and it can be safely deleted (assuming you don't have a gradle.properties or similar with any settings you want to save - but there is no need to delete it).
It is not a bad idea to do a gradle init in your Android Studio project - this will give your project its own Gradle that you can upgrade at your leisure without having to rely on the globally installed Gradle.
I have a strange problem that suddenly appeared in android studio. I created a new cpp file, and included it in Android.mk. Then I synced the project. However, android studio still complains that the file is not part of the project and that I need to sync, BUT the whole project builds successfully.
Likewise, if I remove one of the other older files from Android.mk that it did not complain about, and resyncs and then tries to build the project, as expected the build fails, but android studio does NOT complain that that file is not part of the project anymore.
So somehow, suddenly the android studio editor is not able to correctly identify which files have been synced and are part of the project, but during compilation everything works as expected.
Does anyone know how to fix this annoying problem? I have tried clean project, invalidate caches/restart as well as updating android studio without luck (AS version 3.4).
I used Build > Refresh Linked C++ Projects menu and it worked.
I had a similar problem. Like yourself, I have tried everything.
Invalidate and Restart: Doesn't work
Manual deleting folders: .gradle .idea .ndkbuild etc. doesn't work
Clean, Rebuild, Link C++ Files: Doesn't work
One thing that kind of helped me was: I changed the NDK version. I compiled, then got a compilation error (didn't matter because it was the wrong version of NDK anyway), then I reverted to the original NDK. This appeared to solve the problem, however, it got back again.
My solution was to reset Android Studio to factory settings. If you are on Linux, you can start by deleting these folders:
rm -rf ~/.android
rm -rf ~/.AndroidStudio3.4
Then you download and run your Android Studio and not import anything from anywhere.
I suspect the problem was caused by one of the plugins I've installed.
It may be a good idea to backup those two folders from time to time and reload them from there if necessary.
EDIT: It seems that my problem persisted after the above solution after adding more .cpp files. After seeing that, I searched where that popup came from. It follows that "This file is not part of project..." popup is pushed from ndk-build. (Class name: NewCppSourceNotificationProvider - StaleCppProjectNotificationPanel). What I tried, and what worked so far; I used Android Studio 3.5 Canary13 with NDK version r19c (Stable version). I hope this helps you.
Problem Environment
Android Studio 3.5 RC 2
gradle-4.10-all
com.android.tools.build:gradle:3.2.1
Solution
Update to:
- gradle-5.5.1-all
- com.android.tools.build:gradle:3.4.2
Steps
From the project root run (note this has to be done first):
./gradlew wrapper --gradle-version 5.5.1 --distribution-type all
In root build.gradle file:
buildscript {
//...
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
//...
}
}
I have similar problem, it could be the compatibility issue of gradle version and gradle plugin version, because my solution is replacing the old configuration
// build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
...
// gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
with the following new one by changing gradle version from 4.6 to 4.10.1.
// build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
...
// gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
After that, Android studio can index and track my new cpp files in project.
fix this by update my 'com.android.tools.build:gradle'
Had the same problem with Android Studio 4.0.1 and the latest gradle at this time (6.1.1?). The problem went away after I exited Android Studio and deleted .gradle and .idea folders in the project main directory, plus deleted .cxx and build directories in the affected module directory. I'm not sure which really helped, but most probably deleting .grade and/or .idea
I fixed with update 'com.android.tools.build:gradle' in the artic fox version 2020.3.1
For those struggling with this for me I made a small change to CMakeLists.txt (I altered the version required). This forced the CMake to regenerate, and all missing files were added. This is quicker than the other options listed here.
This applied to NDK 21, so YMMV!
Invalidate cache and restart and you should be good. However, make sure you checked the Clear file system cache and local history checkbox.
Android Studio displays in all java files in red : “cannot resolve symbol R” but the project compiles and runs.
I have tried every solution here:
Android Studio "cannot resolve symbol" but project compiles and works, but with no luck.
I tried to :
invalidate caches and restart android studio
delete .gradle and .idea folders
clean and rebuild the project
install a new version of android studio
mess up with gradle file then undo changes and sync project
One thing that I want to try, but I don't know how to achieve, is to reopen the project from scratch as I was opening it for the first time, but I don't know how to do this.
I also tried answers from here:
Android Studio says "cannot resolve symbol" but project compiles,
but again with no luck.
Android studio version = 3.2.1
dependency versions in gradle project file:
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
classpath 'com.google.gms:google-services:4.0.0'
For some reason that i do not understand ,
this combination of build versions made the issue :
grade version = 4.10.1
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
when i switched to these build versions :
grade version = 4.6
classpath 'com.android.tools.build:gradle:3.2.1'
The issue was solved !
File -> Close project
Open an existing Android Studio Project
Open you project
Hope it will work.
sometimes, R file is not generated because of package name on android manifest is not match with package module that you have.
Is any wrong syntax or spelling in your xml?
Check your layout or any xml file.
Android Studio seems to have a caching issue with R.java occasionally. I rarely have a problem with this, but when I do, I actually open R.java (double press shift and type "R.java") or navigate to R.java under "app/build/generated/source" directory, opening the file and checking if the relevant XML id has been created. If it has, it forces Android Studio to now recognise the id's that are not being resolved. It's quick to try, and doesn't require clean and rebuild.
From your programs menu, open android studio. instead of opening your project from the recent files, select to open a project from your computer and then locate the path to your project. When all else fails, sometimes this works.
Also, try commenting out the support libraries from your gradle implementation, sync your project, and after sync fails comment them back in and sync again. (not sure if that's what you tried already when you said you messed with the gradle file)
In my case,
I am using
- Android Studio version 3.3.1 at home
- Android Studio version 3.2.1 at office
When i pulled projects to my office computer that are firstly created at my home computer ,
Android Studio can not resolved R file but runs application with no error. Because projects gradle and Android Studio version are incompatible.
Only thing that you sholud do, change the gradle version in project level gradle file
classpath 'com.android.tools.build:gradle:3.3.1'
to
classpath 'com.android.tools.build:gradle:3.2.1'
I was facing same issue,
first thought the issue might because of some xml file or naming of drawable resources incorrectly. After analysing, this case wasn't applicable to me.
So
Updating Android studio from older version 3.2 to newer version 3.3.2 along with new build tool version from SDK manager resolved this issue
for me.
I've tried invalidate cache and Restart AS with clean rebuild all the options but didn't work for me.
It says cannot resolve symbol, but it can run.
In my case, I just reload the needed *.jar files to the libs folder.
File >> invalidate caches/restart
Rebuild Project
Sync
Run
Works for me!
It looks like the library did not load my "imports" properly the first time.
That's why the import methods cannot be seen in my main_activity.xml.
This happened to me when I was going back and forth between different SDK versions.
Apparently SDK manager copied all the source files but it didn't finish cleanly. As a result I could compile and run my project just fine but IDE didn't recognize the SDK and reported all java symbols unresolved.
None of the above and other solutions in SO didn't work for me, but just uninstalling/reinstalling the specific SDK version did a job.
If you renamed your package (inside java folder), make sure you change your Manifest package name to the same
The only thing that worked for me was,
replacing,
import package_name.R
with
import package_name.*
simply go to project settings : settings.gradel and change the rootProject.name to your current name
rootProject.name = "write the project name here"
since I upgraded to android studio 3.0.1 I can not continue with my application. Gradle throws the following error: Gradle Sync Issues
Error: Unable to load class 'groovy.lang.GroovyObject'. Possible causes for this unexpected error include: Gradle's
dependency cache may be corrupt (this happens after a network
connection timeout.) Re-download dependencies
and sync project (requires network) The state of a
Gradle build process (daemon) may be corrupt. Stopping all Gradle
daemons may solve this problem. Stop
Gradle build processes (requires restart) Your
project may be using a third-party plugin which is not compatible with
the other plugins in the project or the Grade requested by the
project. In the case of corrupt Gradle processes, you
can also try to close the IDE and then killing all Java processes.
Any suggestions? Thank you very much.
If you made an update to Android 3.0+ do not forget to perform the cache invalidation in Android Studio and restart.
File > Invalidate Cache / Restart
You can try doing the compilation by command line, through the terminal that has integrated Android Studio:
./gradlew clean assemble
I have changed the following line in project's grandle.wrapper.properties file:
From:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
After that i could successfully build my project again.
Not sure why it was not working with version 4.1 since both versions exists in %HOMEPATH%\.gradle\wrapper\dists folder.
I got the following error message when I was importing a project from github:
Failed to refresh Gradle project 'XXX'
The project is using an unsupported version of the Android Gradle plug-in.
Fix plug-in version and re-import project
This is not a duplicate of this because your get thee error message before
gradle/wrapper/gradle-wrapper.properties
is generated.
The problem appeared after updates. The updated Android Gradle plug-in did not support the outdated version of Gradle I had. But the error message is misleading, if you don't attempt different build options you won't see what the problem is.
After downloading a newer version of Gradle, Imported the project again, then:
Use local gradle distribution
Then Gradle home set to the folder where the new version of gradle was downloaded
that solved it
Edit: From Scott (below comments) : It's preferable to use the wrapper and to change the Gradle version in gradle-wrapper.properties instead of downloading and installing Gradle yourself. As for the Android-Gradle plugin, that's set in the dependencies.classpath block in your build file; see this
I get this gradle-errors in 4 Studio updates! My solution: I copy the Studio-folder, and if gralde throws an error, I copy the old version back. It's not a good way, but until google is not able to deliver an update without producing always the same errors (even if mentioned in many forums), I stay on 4.9 and wait for the first final release.