Skip to content

PDEX error #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
omerjerk opened this issue Aug 11, 2015 · 8 comments
Closed

PDEX error #132

omerjerk opened this issue Aug 11, 2015 · 8 comments

Comments

@omerjerk
Copy link
Contributor

import android.view.MotionEvent;
void mouseDragged() {
 MotionEvent me = (MotionEvent) mouseEvent.getNative();
 // code here, like me.getHistorySize() and other Android-y things
}

Whenever I open the above sketch, I get the following error :

Cannot find "android.view" library. Line 1 in tab test
java.lang.NullPointerException
    at processing.mode.java.pdex.ASTGenerator.getSuggestImports(ASTGenerator.java:3309)
    at processing.mode.java.pdex.ErrorCheckerService.updateErrorTable(ErrorCheckerService.java:982)
    at processing.mode.java.pdex.ErrorCheckerService.checkCode(ErrorCheckerService.java:534)
    at processing.mode.java.pdex.ErrorCheckerService.run(ErrorCheckerService.java:332)
    at java.lang.Thread.run(Thread.java:745)

Any idea what does it mean ?
Is there a problem with Android mode ?

@benfry
Copy link
Contributor

benfry commented Aug 11, 2015

It's probably that android.jar needs to be added to the list of library JARs so that the error checker service is aware of it. Check out the recent change I made to the main PDE so the result of getCoreLibrary() was added and could be checked against. @Manindra29 wrote the ErrorCheckerService code and can probably provide other pointers on how it should be handled.

@omerjerk
Copy link
Contributor Author

I'm not getting it.
Where do we need to add android.jar ?
Right now, getCoreLibrary https://github.com/processing/processing-android/blob/master/src/processing/mode/android/AndroidMode.java#L89 returns null.

@Manindra29
Copy link
Member

Were you able to find out why the classPath object is not getting
initialized (as per our discussion)? Android.jar should be added to the
classPath object's search path.
On Aug 13, 2015 5:50 AM, "Umair Khan" [email protected] wrote:

I'm not getting it.
Where do we need to add android.jar ?
Right now, getCoreLibrary
https://github.com/processing/processing-android/blob/master/src/processing/mode/android/AndroidMode.java#L89
returns null.


Reply to this email directly or view it on GitHub
#132 (comment)
.

@codeanticode
Copy link
Contributor

@omerjerk @Manindra29 I still get "Cannot find "android.view" library. Line 1 in tab sketch_150817b", but not NPE after merging PR #134

@omerjerk
Copy link
Contributor Author

I'm also getting this.
Even the NPE is too random. I get it some of the times and sometimes not.

@codeanticode
Copy link
Contributor

see my last comment in #134

@Manindra29
Copy link
Member

I found the cause of the NPE bug. It's because of a race condition. The classPath variable (which was null here) is initialised in ASTGenerator.loadJars(), which is called from ErrorCheckerService.prepareCompilerClasspath() in a separate thread. Due to a race condition, when a sketch is just being loaded, classPath is sometimes accessed before it has even been initialised and thus the NPE is thrown.

@Manindra29
Copy link
Member

I can add a null check as a stopgap fix, but this probably needs a second look.

Added fix in processing/processing@cfe5187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants