How do I fix a NoClassDefFoundError while launching Android LibGDX Project? - java

I am currently learning the LibGDX game engine (version 1.9.4) and I keep running into a compiling error when trying to run my android version of my project. I did some research and found this article and followed the solution that was listed on that question but the same issues keep occurring log.txt.
I tried adding the core file directly to the build path like so but still the same issue.
Is there something I'm not understanding about the error message? If so what is it?
Thank you in advance.

Right Click your Android project->Properties->Java Build Path->Order and Exports Export all your jars that you are using.
still having problem running project on android check if JRE is set to 1.6.
Change the JRE from the main Java Project from 1.7 to 1.6 and try to run it on android.
Eclipse-> main-java-project--> Expand the directory--> Right click on JRE System library--> Check "Execution environment" --> select JavaES 1.6 jre6-> Click Ok

Related

JRE System Library is always unbound in Eclipse? (An internal error occurred during: "Launching Main". Model not available for helloWorld)

THE PROBLEM
I've been developing in Java for years, but a recent install of my tools on a new computer (Windows 10) has resulted in the strangest problem. When I create a new project, almost everything is underlined in red. The error reads Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor:
WHAT I TRIED:
A quick search online reveals that I should JRE System Library is most likely unbound, so I change it: Properties >> Java Build Path >> JRE System Library >> Edit:
All of the red lines go away, but I can't run my program. An Error reads:
An internal error occurred during: "Launching Main".
Model not available for helloWorld
On closer inspection, Eclipse shows an error in the src/test folder, but there are no files there.
When I restart Eclipse, all of the red lines reappear and I have to do everything all over again. It also cannot find the JUnit dependencies either, and I have to manually add JUnit 4 library to the build path.
DEETS YO:
OS Details:
Windows 10
Eclipse Details:
Version: 2019-09 R (4.13.0)
Java Details:
Java 13.0.1
Alright, so none of the posted suggestions worked but I independently found out what was wrong. In general, I've found that this solves a lot of weird Gradle activity, including the ominous "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.6-all.zip'" that a lot of people have problems with once they try to use Gradle with new versions of Eclipse.
Solution
When you install Eclipse, there's a Buildship Gradle Integration plug-in that is visible in the Eclipse Marketplace (it has a little graphic of an elephant next to it). When you get modern versions of JavaEE Eclipse, it comes with that installed.
The problem is that this isn't the most updated version of it.
So you have to click the button that reads "installed" and it'll update it. After you update it and restart Eclipse, your most recent version of Gradle will work.
When using gradle run this:
gradlew cleanEclipse eclipse
this will re-generate the eclipse project and this helped me
Under a fresh Eclipse, we encountered this "Model not available problem" on projects that do not use Gradle, but maven.
To update gradle did not change anything. We assume that there is a conflict between m2e and this plugin. We found 2 solutions :
A) Add gradle nature (even if unused)
Right-click on the project
Configure
Add Nature (elephant logo)
Run your app, enjoy
B) Uninstall gradle. (if not used and not mandatory for your eclipse version)
Help/Eclipse MarketPlace
Search "Gradle"
Go to "BuildShop Gradle Integration 3.0" (the elephant) which is indicated as installed and clic on the grayed installed button.
Uninstall it. It will restart eclipse.
Run your app, enjoy :)
In my case it is resolved by updating Buildship Gradle Integration 3.0 from Eclipse market place

How to fix "JAVA_HOME environment references a directory" in unity3d

I have a problem showed on this screenshot:
Android Resolver
JAVA_HOME environment references a directory (C:\Program
Files\Java\jdk1.8.0_212) that does not contain java which is required
to process Android libraries.
The problem has appeared when I imported GoogleMobileAds package to insert AdMob ads to my project. I tried to create 2 local variables "JAVA_HOME" and "PATH" in environment variables using this guide https://null-code.ru/solution/157-reshenie-exception-jar-not-found-windows.html , but it doesn't help me.
It is a Unity bug. To fix:
Edit->Preferences->External Tools
Uncheck Android SDK Tools Installed with Unity (recommended)
Press Browse -> It might update the filepath
Recheck Android SDK Tools Installed with Unity (recommended)
Then:
Assets->Play Services Resolver->Android Resolver->Resolve
This has been tested and works with Unity 2019, Unity 2020, and Unity 2021.
try
Assets-> Play Services Resolver-> Android Resolver-> Delete Resolved Libraries
check is your Java set true or not:
go to cmd and type JAVA -version
if this appeared means your JDK is set if not check this link: https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
after these, if you have the problem again update your JDK
from https://www.oracle.com/technetwork/java/javase/downloads/index.html
i was using admob plugin in my project and this is how i resolved the issue after trying all given solutions.
reimport the admob plugin / plugins you are using in your project. (i just reimport the latest version of admob plugin and issue resolved)
For me it was similar to this answer https://stackoverflow.com/a/57361245/2149955 but just a bit different so sharing a separate answer for when you haven't installed the tools through unity hub.
In Unity:
Edit->Preferences->External Tools
See error messages "You are missing the recommended <TOOL>. Install the recommended version using Unity Hub"
In Unity Hub:
Installs -> My Unity Version -> ... -> Add Modules, Twirl open Android Build Support -> Check Android SDK & NDK Tools (I also checked OpenJDK)
Press Next -> Accept Terms
Wait for install to finish
After that finishes, back in Unity:
If you look in external tools again, the error messages will be gone
Assets->Play Services Resolver->Android Resolver->Resolve
Update to Unity 2019.4.10f
fixed it
When I wanted to make an app for Android, I got this and many more as errors. Nothing worked, including the solutions here. I tried both Unity versions 2020.3.5f1 and 2019.4.22f1, it didn't work.
I figured out that the problem was due to "Android Built Support" not being fully installed. I did the following and the problem was gone:
Unity Hub (my version 2.4.3) -> from the left menu, go Installs
Click the 3 dots in the upper right corner of the Unity version you want (I used 2019.4.22f1) -> Add Modules
From Platforms, find "Android Built Support"
Its check box was checked because I installed it before, but if you don't have it, first install it
Display its submodules with the arrow to its left; "Android SDK & NDK Tools" and "OpenJDK"
Check their check boxes, next and install
Restart Unity
When you open the project, it resolves
It gave me another warning after the resolve, so I made sure that the problem was gone by doing "Assets->External Dependency Maneger->Android Resolver->Force Resolve" in the project again.
I faced this error when I wanted to build for Android. The reason I have faced this is that I had 2 Unity versions (2019.4.9f1 and 2020.3.3f1), and my JAVA_HOME was configured to use the java folder inside 2019.4.9f1. I then uninstalled and removed 2019.4.9f1, and after that, I got this error when trying to build in 2020.3.3f1.
I changed my JAVA_HOME variable permanently, following the link below:
How to set JAVA_HOME in Mac permanently?
Restarted my Macbook.
Went to Unity -> Preferences -> External tools, unchecked NDK, JDK, etc., clicked the Browse button that appeared, and selected the folder under 2020.3.3f1 manually for JDK.
(In the end, no folder should change when you uncheck and check again)
Simple fix. I got this message about Missing the JDK. If you have one that is similar or pointing to the wrong JDK you can try this fix.
Here is the Error I was getting:
I solved this by:
In Unity goto "Edit->Preferences->External Tools"
Unchecked the box "JDK Installed with Unity (recommended)", and noticed that the Path was pointing to an Old version of Unity I had uninstalled.
Changed the Path to the current version of Unity I am usings, OpenJDK directory.
Re-checked the box "JDK Installed with Unity (recommended)"
Then was able to build my game, and build to my android phone just fine.
Note: If your having problems with the SDK or NDK you could try this solution, by unchecking, and re-checking their respective boxes.
This Worked For me:
If u had rectified
JAVA_HOME,
JDK SDK files &
every possible way and solution does not show up try
preference -> in android untick the JDK installed..,
if you see a change in directory then just re tick,
copy path of JDK and uncheck,
finally paste the path close(x) preference TRY BUILD & RUN
Next time you open Unity Editor then try to check & uncheck JDK we have to see the same directory both ways
there is no sdk if you install unity editor without hub.
it seems unity want to use the versions they want. so it's very poor support for previous historty version.
there is a workaround. you can install a version offically recommanded.
and then copy the sdk, ndk, openjdk folder from the offical version folder to the folder you are using. for windows, these folder is like this:
from:
C:\Program Files\Unity\Hub\Editor\2021.3.21f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
to:
C:\Program Files\Unity\Hub\Editor[your_version]\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK

Unable to config and run a Java project in IntelliJ

Me and a few other students are building a game with Java at university. Someone else setup the basic structure for the project and i pulled the repo and tried to run it.
When i run it i get
this window
When i open the config, i am unable to add the main class, it is located in the file shown in the image. The OK button is disabled. You can see that here.
I'm running the latest version of IntelliJ, JDK 9 and Windows 10. The project in question is built with LibGDX. The full repo and folder structure can be seen here.
I am able to setup my own project and run my own apps, i just can't run this specific project.
Please help.
I think, since you have no "Java" directory, Intellij does not recognize any folder as Java Sources. You'll have to do that manually by rightclicking and mark the desired directory as Source root.
I figured out what the problem was, and of course - it was obvious. The project was setup with an old version of Gradle (2.4) and i was running Java 9. I installed Java 8 and made the project run.
The OK button was disabled because the project hadn't built properly (i though it had) so it couldn't find the class i needed to run it.

Android app project in eclipse has many package errors, how do I fix this?

I was working on an app about a year ago, and kinda forgot about it for some time. I want to get back into it, but every import has an error. I feel like I am just forgetting something simple, but I dont know what it is.
standard java projects (non-android) work fine, but anything android related has errors. I tried updating to the newest sdk (23.0.2), but that did not fix the problems.
here is a screenshot of what is going on.
Edit: I also just insalled the newest build tools, and all the extras in the android sdk manager. This did not fix the problem.
edit 2: It seems that if I go to the Library build paths, the JRE System Library can't be added. If I added, the name of it changes to "Unable to get system library for this project" This only happens with android projects, and not with non-android projects.
Final edit: the problem was fixed by changing the android target version
The following steps could help:
Right-click on project » Properties » Java Build Path
Select Libraries tab
Find the JRE System Library and remove it
Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
After this clean your project.

R.java never appears

When I work on an android application in Eclipse, R.java never appears. I did the following to try to fix it:
delete ~/.eclipse folder
reinstall eclipse
create a new workspace
reinstall android developer tools
reinstall operating system
None of it worked. Even the Hello World! application that is created by default won't build. What do I have left I can do?
UPDATE:
There aren't any problems in Problems other than the two "R cannot be resolved to a variable"s. The Error Log tab shows an error Failed to load properties file for project from when I created the project. I think that may be a good clue as to what the root issue is.
ANOTHER UPDATE:
It's not a permissions issue, since the same thing happens when I run Eclipse as root. 'Fix Project Properties' does nothing. When I comment out the references to R.java, the problem is not resolved (the reason it doesn't run is [2013-07-08 21:47:37 - AppName] Could not find AppName.apk!
)
YET ANOTHER UPDATE:
running eclipse as root works now.
OS is 64-bit Arch Linux
Make sure that you have no xml related error( open and check all xml files, including the manifest manually).
Clean your project.
Change the build target version.
Make sure that you have Android SDK build tools. It comes on updating the ADT plugin.
Try these things:
Check in the properties of the project, in the Android tab if you have downloaded the version of the API that you are using. (See this in the SDK Manager)
Look into your /res folder. Scan for every file. Does any one has problems? If one resource has a problem, the R.java file is not generated.
Check the AndroidManifest.xml file. Look for warnings or problems, especially the use of the <uses-sdk> tag.
If none of these appointed the problem, try to build a simple java application. Does it work? Are you using the JDK 1.6?
Finally, if you are still stuck, download the Android ADT and use it as your IDE. It has all you need.
If your O/S is 64-bit Linux you will encounter Problems with the ADT because it is a 32-bit application. You have to install the following 32-bit libraries:
sudo apt-get install ia32-libs

Categories