How to import android email source code into eclipse project? - java

I downloaded the android Email app source code [version 2.2] from here. I deleted the .classpath and .project file so that I could import an existing android project. Everything seems to have worked. However, I get quite a few recurring errors such as:
Attendees cannot be resolved to a
variable
android.provider.Calendar cannot be
resolved to a variable
Calendar cannot be resolved to a
variable
I have set the correct android version 2.2, what am I missing?
Thanks all for any help

I faced the same issue with Email. I fixed the issue, by adding the following jars into the build path and thus, all the errors were resolved.
../out/target/common/obj/APPS/Email_intermediates/classes.jar
../out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
But you need to make the Application build using the platform.

Many of the included applications cannot(or at least could not) be built with the SDK, as they depend(ed) on non-exported functionality that is only "visible" during the system build. I'm not sure if Email is still in this category, but it was in the cupcake days.
There are three potential workarounds. Best is to rewrite those parts of the application to instead use functionality which is exported in the SDK, and thus fairly stable.
Next up is to use reflection to pick up the missing pieces at runtime.
Last is to make do-nothing dummy classes for the needed non-public platform pieces, within your project. These are enough to let the program compile, and at runtime they get rejected due to name collisions with the hidden system functionality, so you end up utilizing the real classes rather than the dummies.
The proper thing to do is to build the application with the platform build system, rather than the SDK.

Related

Java intellisense not working when imported projects not available

I'm reviewing an isolated Java project in VSCode. By that I mean that I have the project itself, but not any of the projects that it depends on. From what I can tell, the result is that Intellisense has been turned off for the project, which makes navigating around the code a pain.
For example, you can see below that VSCode can't find the definition of a method, even though it's just 3 lines down. On the side, you can see the errors it's encountered trying to load various artifacts.
Is there a way to turn Intellisense back on, at least for the objects that are defined within the project itself? I have the MS Java extension pack installed.
To clarify, these are internal projects that it depends on and I don't have on my machine.
I just noticed there's a feature that might help you get around this. Check out "Lightweight Mode" here: https://code.visualstudio.com/docs/java/java-project
Maybe this will get away from having access to mvn full resources and just get the quick-n-dirty navigation as the docs seem to indicate!
Lightweight Mode
VS Code for Java supports two modes, lightweight and standard. With
lightweight mode, only source files and JDK are resolved by the
language server; with standard mode, imported dependencies are
resolved and the project is built by the language server.
...works best when you need a super quick-to-start and lightweight
environment to work with your source files, for example, reading
source code, navigating among source code and JDK, viewing outline and
Javadoc, and detecting and fixing syntax errors. Also, code completion
is supported within the scope of source files and JDK... Lightweight mode doesn't resolve imported dependencies nor build the project.
Your project throwed project build error: Non resolved parent pom for com.....
When errors are resolved, the intellisense should work as normal.
Please have a look at this question. Try and see if error goes away.
Project build error: Non-resolvable parent POM.

How to break up one android package into several packages

I have a legacy app with 168 modules in it and I would like to break it up into several java packages from:
com.mycompany.ediary
to
com.mycompany.ediary.util
com.mycompany.ediary.data
com.mycompany.ediary.services
...etc.
This would be to better organize the code. I read where it is ideal to have less than 30 files per package and as you can see, this is way over this. What is the best way to do this? I am currently running Android Studio 1.5
As #Antoniossss says "Just do it!".
Following a slight explanation...
In the older Eclipse days there was a link between the Java packages, and the Android manifest package (now referred to as the "application ID") in the app. This was enforced by Eclipse (almost) requiring that you put your code into a Java package that was named the same as the application ID.
Changing the root (Java) package of your code in Eclipse got a bit tricky, and generally you would want to do that by using the Android Tools menu. This made sure that the R class was correctly imported after the change.
Android Studio makes it much easier to separate the 2 concepts. Plus the terminology makes it easier now, since the accepted term "Android manifest package" is now the "application ID".
This gets set in your gradle build file:
applicationId "mobi.glowworm.demo"
How you organise your Java code does not depend on this value at all anymore. You can use any package structure you want to.
So, yes, "Just do it!"
It wasn't as easy as I thought in Android Studio, yet easier than I thought at the same time.
Adding new packages is basically adding new directories to your project structure, by adding new "packages" and letting Android Studio do the work of refactoring it all in your code. I did have some collisions with the manifest-merger-release-report.txt file, but after manually fixing those and updating my manifest as well, I was able to break up the files into a more organized format. I didn't have to touch the gradle files at all.
Right click on the java folder in your app, select New -> package - then enter in the full package name: com.mycompany.ediary.utils. Then cut and paste the files you want to add to the new directory/package, when prompted for reformatting, hit "reformat", then allow Android studio to do its magic.

Lotus Domino Java Script Library Compile Error

I had an issue where I was getting the following error in the Problems view when attempting to save/compile a Java script library in a DB held on a server. I'm using DDE 8.5.3 (Note, I've changed the app and the lib names):
Project 'app_name.nsf.java-lib-name.javalib' is missing required library: 'C:\lotus\notes8\jvm\lib\axis\axis.jar'
It's worth noting that I'm using the Eclipse based Java editor, this issue doesn't happen if I use the traditional editor.
My script library had a number of JAR files associated, however none of them were included via the path which appeared to be causing the issue. Also it couldn't have been some deeply concealed dependency thing as all of the included JARs are custom built and none of them user or require Axis.
I also did a test creating a fresh library without pulling any external JARs in and the same error occurred.
It turns out the problem was being caused by the use of "JavaUserClassesExt" in my local notes.ini. I've recently been using a LN client app which depends on Axis and part of the install process includes dropping the relevant Axis files into a custom directory within jvm/lib/ext and then updating the ini to include those files using "JavaUserClassesExt" when launching the JVM.
I guess the issue has only shown up now because I've recently had to change the location of my LN install from the path indicated above (lotus\notes8) to something slightly different (lotus\notes853). I copied my ini across from the original install location which is why it still references the old path. Once I removed the references to the wrong path, the error cleared up.
So I can kind of understand what is happening, the JVM is attempting to load all required files on the classpath but is running into an issue because the files being requested via "JavaUserClassesExt" can no longer be found.
What I don't understand is why it's throwing this error when I'm attempting to edit a script library in a completely different database which has nothing to do with the Axis framework. I'd expect a compile error if trying to import anything to do with Axis based on it being on my local classpath, but to throw this error when the library has nothing to do with Axis seems confusing and incorrect to me.
As I mentioned, this only happens when using the Eclipse based Java editor so I presume this is a bug with that version of the editor.
Has anyone come across anything similar? Would this be classed as expected behaviour or can anyone confirm if this is a bug?
I realise this is a pretty edge case issue but would be interested in any insight.
Cheers,
Lee

Eclipse doesn't import java libraries on cold start, plus other compiling errors

Eclipse is giving me a few problems.
After a cold start and the loading of android libs, Eclipse underline the import statements or says that java.lang.Object couldn't be found.
Closing it and reopening often fix the problem. If it doesn't, another close-open fix it definitely. But it shows at each cold-start.
It also gives
"The type java.lang.Enum cannot be resolved. It is indirectly referenced from required .class files"
"The project cannot be build until build path errors are resolved"
But if i restart the build path errors and the enum problem are not show any more(sometimes the enum proble got fixed some time after eclipse's loading finished)
"Project 'xxx' is missing required source folder: 'gen' "
that should be generated automatically generated while building, and still restarting will fix them
In addition, in many projects, while building or cleaning, eclipse says that it couldn't delete the bin/. directory. I noticed that that directory is read-only, and if i try to remove the attribute(even from dos), it immediately return to read-only.
This problems aren't show-stoppers, i still can code and i still can get my apps exported, but it is quite annoying to have to restart eclipse a few times before being able to use it(and eclipse isn't that fast at opening), and i would really know how to fix it.
I searched in the net a bit, but i dind't found nothing useful or that worked.
Is there a way to fix them?
I didn't "unistalled"(it is just stored in a directory) Eclipse, since i should then reinstall android sdk, mercurial plugin, and re download and set up a few libraries i use in quite all my project, and i really hope there is another way.
final notes:
everything works when this problems doesn't show: the app works, logcat too, the right device is used to install the app, so i think java and android sdks are installed just right
I had that problem before so I just saved my projects to a different file and uninstalled everything ( java, android sdk, eclipse ). When I reinstalled it all I put the android sdk on the root of my c drive as I have a windows machine and then instead of picking where java was installed I let it do its own thing. I dont use a mercurial plug in but your "read only" problem could be related to that. Its possible your downloading files that are "read only" and there for you have no way to alter them. Im guessing since you said youve been programing you already know how to set the build paths and stuff. It might just be where everything is installed or something silly like privilege settings on your machine.
What were you using the mercurial plug in for anyway? just curious :)
Have you included the java lib in your project or? For a couple of weeks ago I sat with an project where i absolutly needed some of the methods, so because android just have some of the java lib I imported the need libs and used that.

Approach for fixing NoClassDefFoundError? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
NoClassDefFoundError - Eclipse and Android
I'm seeing this question is getting asked a lot in many different contexts. Perhaps we can set some strategies for locating and fixing it? I'm noobish myself so all I can contribute are horror stories and questions, sorry...
It seems this is thrown when a class is visible at compile time but not at run time... how can this happen?
In my case I am developing an app that uses the Google APIs, in Eclipse, for the Android platform. I've configured the Project Properties / Java Build Path / Libraries to include the gdata .jars and all is well. When I execute in the emulator I get a force close and the logcat shows a NoClassDefFoundError on a simple new ContactsService("myApp"); I've also tried a new CalendarService("myApp") with the same results.
Is it possible or desirable to statically bind at compile time to avoid the problem?
How could dynamic binding of an add-on library work in the mobile environment anyway? Either it has to be bound into my .apk or else I need to "install" it? ... hmmm.
Advice much appreciated.
It seems this is thrown when a class
is visible at compile time but not at
run time... how can this happen?
The build classpath may include JARs that are not being packaged into the APK.
Is it possible or desirable to
statically bind at compile time to
avoid the problem?
It is possible, desirable, and necessary.
Outside of Eclipse, you just put the JARs you need in libs/ in your project, compile with Ant, and you are done.
Inside of Eclipse, one pattern I have had students use with success is to put the JARs you need in libs/ in your project, add them as JARs to the build path (note: not external JARs), and they get packaged as part of the APK. Note, though, that I do not personally use Eclipse, and so my experience with it is limited.
For those having problem I was having the same error with my app. what I did to solve that was create a new project and copy my resource and source folders along with my manifest file into the new project (I deleted in advance those within the new project created) and voila.
When I got this, the problem was actually deeper in the queue; Dalvik converter had failed to convert some of the referenced libraries and still Eclipse allowed me to launch the project.
Check the Android SDK console to see if there are any errors reported.
In my case, I'm using my own library (MyLib) shared between 2 apps. App A was closed when I added a new class to the library.
When I opened App A to work on it, Eclipse recognised the new class, and I was able to reference it. However on running I got the error.
It turned out that the imported library folder in App A (named something like MyLib_src) didn't reflect the changes made to my library project (MyLib).
To solve this I refreshed App A, the changes reflected, and Android could build my project correctly.
I have found no reference to this version of the problem, so thought I would add it to this list.

Categories

Resources