Android Studio build error: Can't load a class - java

I didn't even do anything to the app and it gave the following error:
Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/annotation/plugin/ide/AnnotationBasedPluginModelBuilderService
I configured this project with Java and API 21, and is on Windows OS
What I've tried:
Deleting .gradle
Deleting the entire project
Changing the jre used for build to the jdk I installed on my computer, which is JDK14
Aand it doesn't work. Any help appreciated!
EDIT : One more thing attempted: disabled then enabled the Kotlin plugin, still does not work. Thanks user #Android_id for suggesting the possibility though!

Related

Why can I not resolve String and System symbols in java Android Studio

So I recently deleted the -studio64.exe.vmoptions file and the next time I launched it, it's unable to detect common libraries like 'String' and 'System'. I tried to download Jetbrains IDE also, and it throws the same error-
https://i.stack.imgur.com/EV3EV.png
What I have tried so far:
Change gradle build version
Reinstall Android studio
Uninstall Android studio completely- including jdk and sdk dependencies. Upon reinstallation (technically from scratch), the issue still persisted.
Any help will be appreciated. Thanks!

Error: Could not find or load main class only on my system

My problem is quite specific, so I'm trying to be as presice as possible.
I am working on a libgdx project together with friends using a git repository. We used the libgdx setup app to initially set up the project. First I imported the gradle project into eclipse via file->import->gradle project->existing gradle project. This worked fine. The nested projects popped up in the explorer. Now the first problem arised: When I ran the desktop project as java application I got the error: Error: Could not find or load main class <classname>
Caused by: java.lang.ClassNotFoundException: <classname>. I tested it on a different computer and there was no problem. Same on the computers of my friends. Since I did not find a suitable solution on the web that was working I uninstalled java, eclipse and even the java sdk. I deleted the folder .gradle as well. Afterwards I reinstalled the newest versions of java sdk, eclipse and java itself. Then I tried importing the project again.. But when importing the gradle project the finish button didnt work anymore. So i updated the gradle version in eclipse marketplace. The finish button worked again but the nested projects didnt appear in the explorer. So i added them manually with 'open project from file system. Besides having multiple error warnings, because the imports for the libgdx libraries somehow dont work, I also still have the initial error when running... : Error: Could not find or load main class <classname>
Caused by: java.lang.ClassNotFoundException: <classname>.
I might need to add: I am working on macOS and every pc the project works on is using windows.

Cordova Android Build Exit Code 8

I've been working on a Cordova project for iOS for the last couple of months, and now I want to move over and test the Android portion. I've tried twice of installing the Android SDK, JDK, Ant, and putting them in the Path Environment Variable but I just can't get the app to build. I tried looking around at other questions but couldn't seem to find a definitive answer.
So, when I go to build the Android platform, this is the error that I get:
BUILD FAILED
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:720: The following
error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:734: Compile failed;
see the compiler error output for details.
Total time: 3 seconds
C:\Users\thomas\Desktop\batapp\BatNetting\platforms\android\cordova\node_modules\q
\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s,/c,ant/debug/-f/C:\Users\thomas\Desktop\
batapp\BatNetting\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absoule.dir=
ant-gen
ERROR running one or more of the platforms: Error: C:\Users\thomas\Desktop\batapp\
BatNetting\platforms\android\cordova\run.bat: Command failed with exit code 8
You may not have the required environment or OS to run this project
I'm really not sure what could be causing this. Like I said, I've tried reinstalling the SDK, Java, Ant and double checked the Path. First, I tried pulling the files from a local Git server, then I removed them and copied them straight from the project I had open on the Mac VM I had been working on. I have also tried using both cordova build android and ionic build android, but both have the same result.
Any help would be greatly appreciated!
Update
I've tried creating a new app with ionic and everything in the new app works fine. I've successfully created a project, added Android as a platform, built and ran the Android project. So, it seems to be something with the app that already exists that doesn't seem to be agreeing with me.
I actually figured it out. I was just having a problem with one of my plugins. It required a java library that wasn't in my project. Once I put the library in the project, it was able to build and run fine.

Android Studio org.slf4j.spi.LocationAwareLogger.log

When I installed Android Studio on my mac (OSX Mavericks) and created a project, I got this error:
Failed to sync Gradle project 'project name'
unable to find method 'org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V'
When I first had this problem I had gradle-1.12 installed. I then installed gradle-2.1 and still the same problem. I then installed gradle 1.1 and still the same problem.
I've been trying to fix this problem for the past week to no avail.
Look in ~/Library/Java/Extensions. I had an alias in there for slf4j-api.jar, amongst other old things. Removed that (actually I deleted the whole ~/Library/Java directory :-) and it works fine now.

Android Studio Gradle project sync failed

I'm getting error:
"Gradle project sync failed. Basic functionality (e.g. eiditing) will not work properly."
And Error Log:
Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.10/userguide/gradle_daemon.html
Please read below process output to find out more:
-----------------------
Error occurred during initialization of VM Could not reserve enough space for object heap Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I was trying to delete .gradle folder as I read here. This worked yesterday but today when I started Android Studio the error showed again and deleting .gradle folder doesn't help.
I realy don't know what to do.
Does anyone have any suggestions?
Just a blind guess: try to add something like this to your gradle.properties file in the project:
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
Same issue solve in Android studio by
File -> Settings -> Compiler (Gradle-based Android Projects)
Change the "**VM options**" to
-Xmx512m -XX:MaxPermSize=512m
It worked for me .
The only way I've been able to fix this when it happens is by doing
./gradlew clean
and
./gradlew --refresh-dependencies
and then restarting Android Studio.
If that doesn't work I usually resort to reimporting the project.
I had the Same Issue, and Searched for almost 4 Days but can't able to solve the problem.
But at Last I can able to solve the problem, and for that please follow the steps.
Step 1: Check Your Java Version.
Step 2: If It is 1.7 then Download the New Version i.e JDK 1.8
Step 3: Install JDK 1.8
Step 4: Change the Java Version of Android Studio to 1.8 and the
problem solved...
It Worked for me.
changing compile setting to this worked for me
I was getting the same error in version 2.2.3,So I downloaded the latest Android Studio version 2.3.3, even in the latest version, I was getting the same error, below is my solution :-
Download the latest version of Android Studio from the official site.
In File>Project Structure>SDK Location, JDK Location should refer a 64-bit JDK ex. C:\Program Files\Java\jdk1.8.0_131, even after this, error was not fixed completely.
I checked the project structure, In the File>Project Structure>Project , the Android Plugin version was still 2.2.3, I changed it to 2.3.3 and the build is successful and everything is working smoothly.
This one worked for me.
Close the Android Studio
Delete .gradle folder from c:\users\{username}\.gradle
Open the Android Studio
Clean Project
Rebuild Project
Sync Project with gradle files. See screen shot
Cheers!
Check if the gradle path in File -> Settings -> Build, Execution -> Gradle is correct. I had incorrect path to local gradle distribution there.
None of these worked for me, so this is how I eventually solved my problem:
In the top-level build build.gradle file, remove
'classpath 'com.android.tools.build:gradle:some version number'
sync your project and make sure your gradle location is pointing at the correct directory
Updating Java and the problem is solved!
Control panel > Java > Update Now
I was in that situation, finding near no solution; finally I realized that my firewall was blocking java executable from opening ports/connecting. Try adding a firewall exception for the Java executable. This solved the problem for me.

Categories

Resources