Eclipse libgdx import cannot be resolved - java

I am following this tutorial http://steigert.blogspot.com/2012/02/3-libgdx-tutorial-scene2d.html and i get an error in eclipse for these imports:
import com.badlogic.gdx.scenes.scene2d.OnActionCompleted;
import com.badlogic.gdx.scenes.scene2d.actions.Delay;
import com.badlogic.gdx.scenes.scene2d.actions.FadeIn;
import com.badlogic.gdx.scenes.scene2d.actions.FadeOut;
import com.badlogic.gdx.scenes.scene2d.actions.Sequence;
import com.badlogic.gdx.scenes.scene2d.ui.Align;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Image.Scaling;
all other libgdx imports work fine but these give me the import cannot be resolved error
does anyone of you know how to fix this?

Now that I can see my code, yes - the libgdx version used in the steigert demos is not the latest, and lots of scene2d has changed since then.
http://steigert.blogspot.com/2012/07/13-libgdx-tutorial-libgdx-refactoring.html
You can get his refactored/updated code at:
https://code.google.com/p/steigert-libgdx/source/browse/tags/

Related

The import org.apache.commons.httpclient can not be resolved

I have downloaded the library
added the library
refreshed the project
imported the library to project
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
However i still get the error
The import org.apache.commons.httpclient can not be resolved
can you please tell what is the problem with it?

Android Studio not recognizing import statements

I have a multitude of problems stemming from one central issue: Android Studio isn't recognizing imports.
For example, in my class "ActivityAbout" I have the following import statements:
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;
However, in the IDE (using the first import statement as an example), the import android.content. is appearing grayed out, and when I hover over it, it says "unused import statement" the Intent part is appearing red, and when hovering over that, it says "cannot resolve symbol Intent." This occurs for each of my import statements, with the first part being grayed out, and the last part being in red.
Now, this provides a multitude of issues in my code, as anything relating to those import statements appears red and when hovering over it, I get the message "cannot resolve symbol ____"
Here's the kicker- my app still compiles and runs upon opening it on my phone.
I suppose my main issue is that it is incredibly annoying, and auto imports doesn't work either. (I have checked off 'show import popup' in the settings, which is the answer I found for other people having issues with auto import not working). My other concern is that this would make my app ineligible for release on the play store. I'm still looking into the publishing process, so I don't know if that is actually an issue or not.
My question (if no one has an answer for how to fix this) is: is this a problem with the IDE itself or the code?
EDIT: added the other import statements
I just had this issue.
I resolved it by clicking File > Invalidate Caches / Restart... > Invalidate and Restart.
When Android Studio restarted and indexed all my code again, the issue was gone.
I have no idea what caused it...
I had a similar issue with my project. I resolved it by going to File > Sync with File System and then closing the project and importing it again
You may need to resync with the gradle again but hopefully it works for you

Cannot resolve "framework" in simple JOGL example

I am trying to run the JOGL java example called "GL4 Hello Triangle", which can be found at
https://github.com/java-opengl-labs/helloTriangle
I copied the code to an eclipse file, and I have linked to jogl, and I can import all the com.jogamp.opengl.... However, when I try to import
import framework.BufferUtils;
import framework.GlDebugOutput;
import framework.Semantic;
I get the error
"The import framework cannot be resolved"
What am I doing wrong?

LibGdx Tools Error

I have problem with building my Core/Desktop/Android project in IntelliJ after adding gxd-tools.jar as Core Library.
Please note my imports:
package com.enplug.exampleapp;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.enplug.common.logging.ILog;
import com.enplug.sdk.hosting.AppState;
import com.enplug.sdk.hosting.HostedGame;
import com.enplug.sdk.interfaces.FontType;
import com.enplug.sdk.interfaces.IServiceProvider;
import com.enplug.sdk.model.social.SocialFeedDefinition;
import com.badlogic.gdx.graphics.g2d.freetype.*;
import com.badlogic.gdx.tools.imagepacker.TexturePacker2;
and TexturePacker code:
TexturePacker2.process("C:\\pokusatlas", "C:\\pokusatlas", "spritesheet");
Screenshot of my error:
What should I make to avoid this error?
Check the guide about adding libgdx tools to the gradle dependencies. Let me quote the important part:
Tools Gradle
Core Dependency:
Dont put me in core!
==> you should not add gdx tools to core project! Put it in desktop project instead:
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
The issue with adding libgdx-tools to core project is that the libgdx-tools are not compatible with android/ios projects. But android/ios depend on core project, so you cannot add plattform-dependent libs to your core project.
But even if it would be possible to include in core project it wouldn't be a good idea either. I mean you are not going to run TexturePacker in your released apps anyway. Just run TexturePacker during development and include its output in your android assets folder.

Eclipse: Java application size

So i made it finally to the final stage of my simple java app that runs under windows and is used to get the user name and log it in an remote excel file. up until now everything is ok.
When i Externelize (does that word exist?) the app to make it a runnable jar the size of the app was 22Mo! wich is huge since i want to use it in an email (outlook).
Here come the question (finally). Can i delete any of the default java jars in the classpath and the app will still run ?? if yes, which ones??
NB: i tried including the imports in the SS if it does help
NB2: the Jar of the app it self is just 20Ko , the ressources are around 22Mo .
By the way thank you all for helping me make this app it was thanks to this website eventhought i didn't ask any question up until now you'll still answered them all..You rock !
Those are my imports:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wb.swt.SWTResourceManager;
EDIT: So after the discussions i managed to reduce the size of the app to 8Mo by deleting some of the jar in the referenced library (org.ibm.icu.jar). The app still runs perfectly without it
A jar file is just a zip file, so what I would do is simply unzip the file and see what comes with it and what is large. The standard java libraries, should not even be part of your JAR as they are part of the JRE.
However, my suspicion is that you use Apache POI and that is huge. So if you are writing to an Excel file you might have to stick with that size or find another library.
You could for example write the output as CSV which is very lightweight.

Categories