Importing from GitHub to Eclipse - java

I have actually managed to import a project from GitHub to Eclipse, but my problem is when I try to run the project it keeps saying fix errors on source files. Now I know that the code should work as the person who wrote this app has it in the Google App store. This keeps happening for me on all the projects I have downloaded.
Are the suggestions to what I am doing wrong?
Thanks for the replies, I am new to the whole programming world, so I am not sure whether or not the project has a build file or not.
As #Andres has said, my initial thought was that it was to do with the JDK/Android development kit being not the same as I have on Eclipse.
A link to the project is https://github.com/glebpopov/Hacker-News-Droid-App.
The first error I get says in the console window
Unable to resolve target 'android 7'
I also have this example for the beginning of the class Activity Helper:
public class ActivityHelper {
private static final String TAG = "ActivityHelper";
protected Activity mActivity;
protected SharedPreferences sharedPref = null;
And the error here for the second line of code say:
String cannot be resolved into a type
The error here for the third line of code says:
Activity cannot be resolved into a type
And there are plenty more across the whole code.

Some possible causes are:
The version published on GitHub has errors, and is not the same that is published on the google app store.
The project has dependencies that have not been resolved, because of your Maven (or similar product) configuration.
The jdk and/or android development kit required by the project are not the same as the one you have on your Eclipse

Related

The plugin `firebase_auth` doesn't have a main class defined in C:\Users\

When adding firebase_auth to dependencies (pubspec.yaml) to my flutter project I'm getting this error:
The plugin firebase_auth doesn't have a main class defined in C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java or C:\Users(username)\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-3.1.3\android\src\main\kotlin\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.kt. This is likely to due to an incorrect androidPackage: io.flutter.plugins.firebase.auth or mainClass entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.
My code is just the dummy code created by android studio and the only thing i added is firebase_auth: ^3.1.3 in pubsbec.yaml , the .json file in the android/app directory and registered the app on Firebase website.
I get the same issue in VS Code, so Android Studio is not the problem.
I would really appreciate any help!
Add the firebase_core pugin because it is essential and if you did everything according to the documentation then flutter clean after that pub cache repair will do the the work. then again run.
I think you haven't added Firebase core in your pubspec.yaml file. Try to add firebase_core 1.7.0 in your pubspec.yaml and then clean your project using this command flutter clean
also Checkout this installation guide

Eclipse java.lang.module.FindException and java.lang.ClassNotFoundException

I recently installed Eclipse 2020-06 and am using JDK 10.0.2. I wanted to test Eclipse using a simple Hello world program:
package eclispeTest;
public class eclipseTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello");
}
}
But I get the error: Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
One quick fix I see for this to delete the module-info.java file but when I do this I get the error: Error: Could not find or load main class eclispeTest.eclipseTest Caused by: java.lang.ClassNotFoundException: eclispeTest.eclipseTest
I saw one potential fix that told me to go to "Check your project build-path and enable specific output folders for each folder. Go one by one though each source-folder of your project and set the output folder that maven would use."
from: Eclipse - java.lang.ClassNotFoundException
But I am new to Eclipse and have no idea what they are talking about.
I have also noticed that when I open the problems tab at the bottom of Eclipse there is one problem that is repeated about 8 times: Description Resource Path Location Type The project was not built due to "Failed to init ct.sym for C:\Program Files\Java\jre-10.0.2\lib\jrt-fs.jar". Fix the problem, then try refreshing this project and building it since it may be inconsistent eclispeTest Unknown Java Problem
Could someone help me figure out what I should try, with baby steps for how I should do it.
Thank you in advance.
PS in case it helps here is a picture of my Eclipse window after I try to run my code:
EDIT: I made a new java project and below is my java project cration window
(I still got the same error)
Fist of all, In order to work the line " System.out.println("Hello");"
you will require two classes
1)java.lang.System
2)java.io.PrintStream
using above two classes the code runs.you don't have to import these class,because JRE(Java Runtime Environment) automatically does for you.
If you are gettting this error
Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
Which means You didn't setup your "Java project" properly with "JRE"
Let create new project to solve this problem
1)Open Eclipse IDE
2)click FILE (top left most)
3)New
4)java project
5)give you project name (make sure that- "use default location checkbox" clicked)
6)IN JRE section - select use an execution environment JRE(edition as required)
7)Then click finish
This would have solved your problem , go create a Class do your eclipseTest. This time it should work.
java project creation should look like this

Why do I have java.lang.ClassnotFoundException while implementing location listener? (using ECLIPSE)

I know that similar questions have been on SO and I have read through and tried to implement the solutions mentioned but nothing is working. The specific problem is like this (using ECLIPSE):
I am trying to implement location awareness in one of the activities (triggered through menu selection) in my app. As long as my code looks like,
"public class MealHistoryActivity extends Activity {...}",
I don't get any error. As soon as I modify it to
public class MealHistoryActivity extends Activity implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener {..",
it throws in the following error:
E/AndroidRuntime(5027): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.activities.MealHistoryActivity" on path: DexPathList[[zip file "/data/app/com.package.activities-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
What I have tried:
Adding up the library projects (support library as well as google play services) and cleaning all the projects.
Including Android Private Libraries for the application as well as the library projects.
Double-checking the API key in android manifest as well as the SHA-1 fingerprint key associated to it.
Using all the internet and network permissions in the manifest that are needed for location services.
Would greatly appreciate any ideas on how to solve this since I am stuck on it for the last few days!
The error suggests that the classes from the google-play-service project are not loading.
Make sure you are referencing a copy of the project in your workspace, and not the copy that is in the sdk directory. Try doing that or deleting the google service project from your workspace and redoing the steps in this guide.
Another possible cause for this is version mismatch. If your device's version is less than the version specified in the above mentioned guide than the google services project will not install on your device at all.

Bizarre NoClassDefFoundError when running in Android

I've tried looking at all the other NoClassDefFoundError threads on here and elsewhere, but they all seem to be a different problem.
My activity refers to a custom FragmentPagerAdapter - let's call it MyFragmentPagerAdapter.
The Activity refers to it with:
MyFragmentPagerAdapter pagerAdapter = new MyFragmentPagerAdapter(getFragmentManager());
ViewPager viewPager = (ViewPager) findViewById(R.id.form_pager);
viewPager.setAdapter(pagerAdapter);
This all seems to compile and build perfectly well in Eclipse. Eclipse can certainly find all the classes - it auto filled the import statement for me.
However, when I try and run the class in Android (emulator or device) I get a NoClassDefFoundError for MyFragmentPagerAdapter and (of course) the app crashes.
I've tried deleting the APK on the device and re-installing in case it was a deployment issue, but it didn't help.
This isn't to do with some 3rd party library - it's my own class that it fails to find!
I have also tried "cleaning" the Project.
I have extracted the apk and inspected the output of
dexdump classes.dex | grep PagerAdapter
and there are references to my class in there, so I can only assume the compiled class is getting itnot the apk - which makes me even more bemused.
NoClassDef refers to classes that are referred by your class (in this case "MyFragmentPagerAdapter") not to the class itself (that's the ClassNotFoundException).
Check the import you have in the class "MyFragmentPagerAdapter" and be sure that they are all in the classpath of your android application i.e. by checking the libs folder and (eventually) other android libraries you are referring to in your project.
Hope this helps.

Java Error: EventDispatchThread.run() line: not available [local variables unavailable]

I get the following error when I try to start my code in the debugger.
EventDispatchThread.run() line: not available [local variables unavailable]
The code is very large and I can't publish it here but anyway here are some details:
This statement seems to crash and I can't step into the constructor with the debugger:
Satellite satellite = new Satellite();
When I put a breakpoint on this line and try to step into the constructor or step over I get the same error as above.
Here are parts of Satellite class implementation:
package tags;
import main.*;
import xml.*;
public class Satellite extends XMLElement {
public static final String[] ATTRIBUTES = {
"XmlFileVersion",
"SatelliteName",
"xmlns:xsi=#xmlns_xsi",
"xsi:noNamespaceSchemaLocation=#xsi_noNamespaceSchemaLocation"
};
public Satellite() {
super(ATTRIBUTES);
setTopLevelElement();
setAttribute("XmlFileVersion",ValueCenter.Satellite_XmlFileVersion());
setAttribute("SatelliteName",ValueCenter.Satellite_SatelliteName());
addElement(new SubSystemList());
}
}
I localized the problem somewhere in the line addElement(new SubSystemList()); . I added a breakpoint here and again tried to step in or step over and now I got a ClassNotFoundException. The debug cursor jumps to an empty window where "Source not found." is written but the Source is 100% available and I also got the corresponding .class files. The other thing is that the Eclipse IDE throws no errors on the syntax check.
I don't understand this. What can cause these errors and why can't I use the debugger to walk through the method calls?
I've updated the Eclipse Helios SR1 for Java Devs and installed the latest java version on my pc.
I know that the code has an endless loop anywhere in here because I get an StackOverflowError Exception if I run it without the debugger. But anyway, shouldn't it be possible to debug through the code, to investigate the real problem? Why is the debugger crashing with other errors or exceptions than a non debugger run?
btw: only one thread and sequential execution.
Hope someone can help.
Edit 1:
Some additional infos. My Workspace has two projects. In one there is the main program with the Satellite and others. In the other project I have many supporting classes like this XMLElement. This structure works for many classes.
By the way: I can step into the XMLElement.setAttribute method but I can't step into the XMLElement.addElement.
The other strange thing is that Satellite is in the same project as the main class but it's also not possible to step into the constructor.
Maybe this helps?
In Eclipse: Right-click the project and select Properties.
Here are the settings you have to change:
Also, find your Run Configuration using Run > Run Configurations ..., select the Source tab and make sure the current project is in the sources list. If not, click Add... > Java Project ...
EventDispatchThread.run() line: not available. This is a common error message for java desktop application developer, who are mainly working in Swing. I also got the same error message but the step you explained doesn't solve my prob.I got the same error message for another issue.That was OutOfMemoryError.So when you are getting this error message the problem you need to find yourself and it's not due to some particular issue.
I resolved this by fixing my Java Swing Code which was throwing NullPointerException.

Categories

Resources