I started learning the Android SDK and I have a problem.
I launched the studio and the android screen didn't show up (YES, I know where the preview tool bar and how to switch).
Quote:
"Rendering Problems The following classes could not be found:
- android.support.v7.internal.widget.ActionBarOverlayLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project."
*Sometimes there is another rendering problem and this is showed :
"Rendering Problems The following classes could not be instantiated: - android.support.v7.internal.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)"
I'm pretty sure its the "appcompat_v7", which is automatically generated in eclipse when setting up an android project. It imports unnecessary features and causes a bunch of build errors.
Delete "appcompat_v7" folder
go to your MainActivity
Delete the import "android.support.v7.app.ActionBarActivity";
change "MainActivity extends ActionBarActivity" to "MainActivity extends Activity"
add import android.app.Activity;
add import android.os.Bundle;
add import android.view.Menu;
add import android.view.MenuItem;
go to res folder and then go to your values folder...delete styles.xml
delete values-v11 folder
delete values-v14 folder
go to menu folder, and click on main.xml...go to "item" tag and delete app:showAsAction="never"
go to AndroidManifest.xml...go to "application" tag...delete android:theme="#style/AppTheme"
go to project at the top...clean and build...you should have no more errors.
Related
I'm trying to work my way through ThinMatrix's Open Gl Java tutorial. And... I'm stuck on video 1. I also worked through the short precursor video where he installed on the dependencies (Including lwjgl 2) in eclipse. Right now I just have the very start of the first class:
package renderEngine;
import org.lwjgl.opengl.Display; //Error is here
import org.lwjgl.opengl.DisplayMode; //And here
//Handle the window
public class DisplayManager {
//Create a display
public static void createDisplay() {
Display.setDisplayMode(new DisplayMode());
}
}
I receive the error, "The import org cannot be resolved". Even though I've added the files to the build path config and I've added the native path in there as well. I've looked at this similar question and effectively tried every proposed solution. I've also tried deleting the project and reinstalling the dependencies. Here is my file tree for reference:
I'd be highly grateful if you could show me what I've done wrong. Thanks so much.
Edit 1:
I've discovered something interesting concerning the line:
Display.setDisplayMode(new DisplayMode());
While both Display and DisplayMode are underlined in red because the import is not working above, one of the "quick fixes" that comes up (even if I delete the import statements) is:
Import 'Display' (org.lwjgl.opengl)
Clicking this writes the import statement at the top (if it isn't there) or brings the cursor to it (if it is there). It then throws the aforementioned error. This seems to indicate that it does actually recognize the fact that the libraries are there, but for some reason can't import them.
The plot thickens.
Edit 2:
To check whether the problem is specifically to do with compatibility with lwjgl2 I've tried importing a class from another library (a linear algebra library called "jblas") with:
import org.jblas.Info;
...but once again I receive the same error. I guess this indicates that the problem is with the way that I am adding the scripts to the build path, with the software itself or a combination thereof.
To clarify how I put things on the build path:
Right click project name -> click "build path" -> click "configure build path" -> click "libraries" -> click on eiether "module path" or "class path" (I've tried both) -> click "add jars" -> navigate to my "lib" folder -> go inside "jars" folder -> select all the jars -> click "apply and close".
Edit 3:
I can import the built-in packages and I can import packages that I've made.
EDIT: DON'T DO THE FOLLOWING: LOOK AT THE EDIT
I downgraded my eclipse version to Oxygen, now I can import the packages without errors. Hopefully, this is remedied eventually so that I can move to the latest version of eclipse. Also, even in oxygen, it didn't work at first. I created a new project and reimported the various jars.
Edit: I faced this problem again, in oxygen
Fortunately this time I resolved it more quickly. I simply added the following snippet to my module-info.jar:
requires org.lwjgl;
Yep it was that simple.
was probably the problem the first time as well. This second problem arose from a second project I decided to make. The last project didn't have a module-info.jar.
That's why it allowed me to not write that line. Meanwhile, the original projects in eclipse 2018/19 did have the module-info.jar file and did have the problem. Maybe in Oxygen it just doesn't happen by default?
Teaching myself Java, still very new. Last night I learned how to import this library into my project in Android Studio. But now I'm confused as to how to actually start using it.
I know that Java works with classes and that supposedly a library is just a collection of classes (and probably others things too...) that you can begin using once you import it. But the author of this library told me to just use this:
BackgroundMail bm = new BackgroundMail(context);
bm.setGmailUserName("sendername#gmail.com");
bm.setGmailPassword("sender_email_password");
bm.setMailTo("receiver#gmail.com");
bm.setFormSubject("Subject");
bm.setFormBody("Body");
bm.send();
But when I try to put that into another one of my classes, I get red errors all over the place. So then I tried to create a Java class within my app's files and I still got red errors. Could someone kindly help me, a total beginner, get started here? I'd like to use this library to send an email in the background of my app.
To import the library:
I followed this answer: https://stackoverflow.com/a/35369267/5241266 and used Approach 2.
MainActivity.Java: this is where I put the import code.
package moviehelper.moviesfree;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
For now, I have not added the block of code that the author told me to use (see above).
The Gradle Console error:
I get the following error when doing Build -> Make Project:
error: package com.creativityapps.gmailbackgroundlibrary does not exist
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
My project tree: I think there might be some problem with this structure. It looks like the library was added as its own project? Although I'm not sure.
If you don't want to use the JitPack approach as documented in the instructions, then look at the settings.gradle file in the Github example.
It includes both modules (app and the library).
Then, once that is setup, you can compile project(:libraryName) in the app/build.gradle file's dependencies section. Again, see the Github sample for the syntax.
With those two steps (plus one to download the library), it should be importable within the app code.
Assuming you followed along with the other steps on the readme, at the top of your code you need to tell the source file to import the classes:
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
public class MainActivity extends AppCompatActivity {
[your code]
}
I would also recommend looking through the sample code included in the github project
You are doing some wrong steps friend. You can follow this
Find your gradle file with name buid.gradle (Project: [ YOUR_PROJECT_NAME ] )
Then find and add this line
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
You are done 50% now. Now press SHIFT+CTRL+ALT+S and wait for a window.
On the Window, select DEPENDENCY TAB on top.
Click on + BUTTON at top right. Click on Library Dependency.
Now paste com.github.yesidlazaro:GmailBackground:1.2.0 there.
Click on OK and exit the window. Gradle recompiles.
Now simply put your code, If RED syntax error showing, Click at the code where error is showing and when a BLUE pop comes, Press ALT+ENTER.
Everything done..!
i had no project in eclipse, and i just followed the steps in this toturial: https://www.youtube.com/watch?v=S9fs1PVTyUc&src_vid=6i78aqugqds&feature=iv&annotation_id=annotation_4141831685
and it opened for me a few projects named:
project,
project-android,
project-core,
project-desktop,
project-ios.
and the project-android had an error.
here is the code:
package com.ak01.projext.android;*
import android.os.Bundle;**
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.ak01.projext.Projec;
public class AndroidLauncher extends AndroidApplication {***
#Override
protected void onCreate (Bundle savedInstanceState) {****
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new
AndroidApplicationConfiguration();
initialize(new Project(), config);
}
}
but it has a few errors although i didn't touch it yet(the number of *'s matches to the line)
*The type android.os.Handler cannot be resolved. It is indirectly referenced from required .class files
**The import android.os.Bundle cannot be resolved
***Multiple markers at this line
-The type android.app.Activity cannot be resolved. It is indirectly referenced from
required .class files
-The hierarchy of the type AndroidLauncher is inconsistent
****Bundle cannot be resolved to a type
It looks like you have not installed the Android developer tools.
To test this, right click your project and press build path. On the side there should be an 'Android' tab, if there isn't you need the android plugin for eclipse.
You can try to use the advanced option to check eclipse as #Tuss said in a comment. Also note that you need the version 19 of Android SDK (it isn't valid the last version at the time of writing this, API 23).
When creating the Libgdx project:
In Libgdx Project Generator open Advanced options.
Check Eclipse.
Generate your project.
In Eclipse:
Open Android SDK Manager: Window -> Android SDK Manager.
Mark if it isn't installed the SDK Plataform for Android 4.4.2 (API 19) and install it.
Finally import the projects with File -> Import -> General -> Existing Projects into Workspace.
So I have just set up Eclipse to work with LibGDX using Gradle. After I installed I noticed there was a problem with the Android package, there was a red cross next to the package. When I opened it further there was a red cross next to src then com.myname.game.android and then in AndroidLauncher.java. When I opened the AndroidLauncher.java, this was the code I got:
package com.faturbansloth.game.android;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.faturbansloth.game.MyGame;
public class AndroidLauncher extends AndroidApplication {
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(), config);
}
}
When I looked at the errors in he code of AndroidLauncher.java they were saying:
-The type android.os.Handler cannot be resolved. It is indirectly referenced from
required .class files
-The import android.os.Bundle cannot be resolved
-Multiple markers at this line
- The type android.app.Activity cannot be resolved. It is indirectly referenced from
required .class files
- The hierarchy of the type AndroidLauncher is inconsistent
-Bundle cannot be resolved to a type
I am using SDK Manager 22.6.2 with the newest Gradle plugin for Eclipse. I have JRE 8 and JDK 7. Is there anyway to fix this problem? Thanks in advance.
There was no Android Version selected by default, so go:
Project -> Properties -> Android -> Project Build Target and select your preferred version
I have no idea why this works but it does for me. I installed the ADT plugin, refreshed the android section and the red cross disappeared.
Refer to the section under "Download the ADT Plugin" to install the ADT plugin.
http://developer.android.com/sdk/installing/installing-adt.html
After that, go to Eclipse > Package Explorer > Left click on Project-android > Select Refresh.
In my application I have a plugin that has a file in a package that tries to import a package that exists in another fragment but with no success.
I've tried to update the exported packages in the fragment and then import the package in the plugin but have had no success.
Please advice.
You may also need to add
Eclipse-ExtensibleAPI: true to the fragment host.
Note that this is a pure-tooling header used by PDE, not an Eclipse or OSGi runtime header.
See here.