Bug 478277 - Android Project wizard blocked with an empty error popup
Summary: Android Project wizard blocked with an empty error popup
Status: NEW
Alias: None
Product: andmore
Classification: Tools
Component: General (show other bugs)
Version: 0.5-M2   Edit
Hardware: PC Windows NT
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: David Carver CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2015-09-24 05:23 EDT by Vincenzo Caselli CLA
Modified: 2017-02-16 09:29 EST (History)
4 users (show)

See Also:


Attachments
Empty error popup (35.32 KB, image/png)
2015-09-24 05:23 EDT, Vincenzo Caselli CLA
no flags Details
Debug problem from sources (174.11 KB, image/png)
2015-09-29 11:34 EDT, Vincenzo Caselli CLA
no flags Details
End of New Android Application Project (154.00 KB, image/png)
2015-10-08 06:05 EDT, Vincenzo Caselli CLA
no flags Details
Two Debug menu items (11.28 KB, image/png)
2015-10-08 06:40 EDT, Vincenzo Caselli CLA
no flags Details
Changes that fixes the appcompat_v7 project (48.04 KB, image/png)
2015-10-08 07:41 EDT, Vincenzo Caselli CLA
no flags Details
Configure menu sub items (52.02 KB, image/png)
2015-10-08 11:20 EDT, Vincenzo Caselli CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincenzo Caselli CLA 2015-09-24 05:23:57 EDT
Created attachment 256812 [details]
Empty error popup

Using the Android Project wizard I am following these steps:
- New, Android Project
- set a name
- leave Contents section unchanged ('Create new project' option selected)
- select a Target: Android 5.0.1 in my case, API level 21
- leave the rest of wizard page unchanged
- press Finish

at this point I get an empty error popup with title starting with "An error o.." (the rest is unreadable since the dialog is small and not resizable, see attachment).

I tried all the following approaches with same results:
1) Eclipse + Andmore 0.5M2 Update site
2) Eclipse + Andmore Nightly p2 site
3) Eclipse + build from sources as instructed at https://github.com/eclipse/andmore, section "Building from Eclipse"

Consider that in last approach my workspace is compiling successfully (only errors on the 2 *linux* plugins, which I closed since I am on Windows).

What I am doing wrong?
Is this not the main wizard to use?
Thank you in advance.

Vincenzo
Comment 1 David Carver CLA 2015-09-28 19:00:20 EDT
Marking as Help Wanted.  Thanks for the bug report, I'll try and get some time to take a look at this.  Also contributions to fix this are welcome as well.
Comment 2 Vincenzo Caselli CLA 2015-09-29 11:25:11 EDT
Just to complete the report, hoping this can be useful, the following is console output when I start the second Eclipse instance from Andmore sources (scenario 3 of first message):



!SESSION 2015-09-29 17:18:25.331 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.platform.ide
Command-line arguments:  -product org.eclipse.platform.ide -data E:\dev\mob-dev\andmore-dev-workspace/../runtime-EclipseApplication -dev file:E:/dev/mob-dev/andmore-dev-workspace/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.mockito 4 0 2015-09-29 17:18:31.711
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.mockito [489]
  Unresolved requirement: Import-Package: COM.jrockit.reflect; resolution:="optional"
  Unresolved requirement: Import-Package: jrockit.vm; resolution:="optional"
  Unresolved requirement: Import-Package: org.hamcrest; version="[1.0.0,2.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:434)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1561)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Parsing sdk content.

!ENTRY org.eclipse.egit.ui 2 0 2015-09-29 17:18:58.712
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.egit.ui 2 0 2015-09-29 17:18:58.716
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Vincenzo'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
Comment 3 Vincenzo Caselli CLA 2015-09-29 11:34:26 EDT
Created attachment 256923 [details]
Debug problem from sources
Comment 4 Vincenzo Caselli CLA 2015-09-29 11:54:54 EDT
The problem seems to be in
org.eclipse.andmore.android.common.utilities.EclipseUtils.createOrUpdateDictionaryFile()
at line 1204
ILocalizationSchema locSchema = LocalizationManager.getInstance().getLocalizationSchema(project);
locSchema returns null
so at line 1209
locFile = locSchema.createLocalizationFile(bean);
I got a NullPointerException

HTH
Vincenzo
Comment 5 David Carver CLA 2015-10-02 11:37:15 EDT
(In reply to Vincenzo Caselli from comment #4)
> The problem seems to be in
> org.eclipse.andmore.android.common.utilities.EclipseUtils.
> createOrUpdateDictionaryFile()
> at line 1204
> ILocalizationSchema locSchema =
> LocalizationManager.getInstance().getLocalizationSchema(project);
> locSchema returns null
> so at line 1209
> locFile = locSchema.createLocalizationFile(bean);
> I got a NullPointerException
> 
> HTH
> Vincenzo

Can you create a patch for this and submit a pull request on github that fixes the issue?   I unfortunately haven't had time to look into the issue right now, but will work with you on any pull requests that you create to fix the issue.

The easiest way to get started is to clone the project from Github. And import it into eclipse.  Some information on doing this is here:

https://github.com/eclipse/andmore/wiki/Contributing

More details on building and bringing the code into eclipse can be found at the following link:

https://github.com/eclipse/andmore#building-andmore

If I can get some time I'll work on getting this fixed myself.  In the meantime, if you feel up to it, please consider submitting a patch to fix the issue and I'll make sure it gets checked in.
Comment 6 Vincenzo Caselli CLA 2015-10-02 13:45:02 EDT
(In reply to David Carver from comment #5)
> Can you create a patch for this and submit a pull request on github that
> fixes the issue? 

Hi David,
I tried to do that, but I don't know what is a LocalizationSchema.
It seems to be a concept of Sequoyah, an Eclipse project inactive for some year now, but Andmore still depends on it.

Can you give hints about the need of a LocalizationSchema and the need of depending from Sequoyah?

Thank you
Vincenzo
Comment 7 Vincenzo Caselli CLA 2015-10-02 17:19:29 EDT
David,
let me explain better:
I don't have a change to submit; I just debugged and found that NullPointerException.

But let's make a step back, just to be in synch:
in order to create a new Andmore project am I following the correct procedure:

- New, Android Project
- set a name
- leave Contents section unchanged ('Create new project' option selected)
- select a Target: Android 5.0.1 in my case, API level 21
- leave the rest of wizard page unchanged
- press Finish

or should I follow other steps?
Comment 8 David Carver CLA 2015-10-06 13:54:22 EDT
(In reply to Vincenzo Caselli from comment #7)
> David,
> let me explain better:
> I don't have a change to submit; I just debugged and found that
> NullPointerException.
> 
> But let's make a step back, just to be in synch:
> in order to create a new Andmore project am I following the correct
> procedure:
> 
> - New, Android Project
> - set a name
> - leave Contents section unchanged ('Create new project' option selected)
> - select a Target: Android 5.0.1 in my case, API level 21
> - leave the rest of wizard page unchanged
> - press Finish
> 
> or should I follow other steps?

That should work.   Unfortunately I think there are multiple wizards currently and I know that some of the old Motodev wizards don't necessarily work. Let me fire up an instance and see if I can get a new project created.
Comment 9 David Carver CLA 2015-10-06 13:58:01 EDT
(In reply to David Carver from comment #8)
> (In reply to Vincenzo Caselli from comment #7)
> > David,
> > let me explain better:
> > I don't have a change to submit; I just debugged and found that
> > NullPointerException.
> > 
> > But let's make a step back, just to be in synch:
> > in order to create a new Andmore project am I following the correct
> > procedure:
> > 
> > - New, Android Project
> > - set a name
> > - leave Contents section unchanged ('Create new project' option selected)
> > - select a Target: Android 5.0.1 in my case, API level 21
> > - leave the rest of wizard page unchanged
> > - press Finish
> > 
> > or should I follow other steps?
> 
> That should work.   Unfortunately I think there are multiple wizards
> currently and I know that some of the old Motodev wizards don't necessarily
> work. Let me fire up an instance and see if I can get a new project created.


Okay, the new Android Project wizard probably should be removed.   It is from the old Motodev Studio plugins and has some bugs.  If you do,  New->Project->Android->Android Application, it should work better.

Either I need to fix the Android Project Wizard or remove it entirely.
Comment 10 Vincenzo Caselli CLA 2015-10-08 06:05:35 EDT
Created attachment 257152 [details]
End of New Android Application Project

(In reply to David Carver from comment #9)
> If you do New->Project->Android->Android Application, it should work better.

Ok David,
I tested it in a blank new workspace.
Under New->Project->Android
I see "Android Application Project" (not "Android Application", but suppose it's what you are referring to)
- click Next
- set an Application Name, e.g. "MyApp"
- set a Package Name, e.g. "test.myapp"
- leave the rest as default (min=API 8, target=API 21, compile=API 23, Theme= Holo Light with Dark Action Bar)
- Next until the wizard end with confirmation of all defaults

I end up with the following situation (see attached image):
- 2 new projects are created: appcompat_v7, MyApp
- error in appcompat_v7: missing "gen" folder (I can solve it creating it from file system and refresh)
- MyApp has errors: it does not resolve the dependency to appcompat_v7

It seems that appcompat_v7 is not generated with the Android ADT Nature: if I add this nature then both projects compile!

Now I would like to Debug/Run:
but if I select MyApp project and do right-click Debug As, then there are these two points:

1) I see two menu items "Android Application" (under "Debug As"), one with a little window icon with a A styled letter inside and one with a green kind-of flattend Android, which one is the right one to choose for degug?

2) no matter which one I choose, I get anyway this error:
  com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
  [2015-10-08 11:59:43 - MyApp] Dx 29 errors; aborting
  [2015-10-08 11:59:43 - MyApp] Conversion to Dalvik format failed with error 1

My Test condition are the following:
- Windows 8.1
- Java 8
- Eclipse Mars 1 JEE package
- Andmore Update site:  http://download.eclipse.org/andmore/milestone/0.5-M2/
- brand new workspace

Any hint?
Thank you
Vincenzo
Comment 11 Vincenzo Caselli CLA 2015-10-08 06:40:31 EDT
Created attachment 257156 [details]
Two Debug menu items

David,
wait, I managed to launch it in Debug/Run!!
What solved the launch problem was changing the Java Compiler level from 1.8 to 1.6 (see post http://stackoverflow.com/questions/27413091/conversion-to-dalvik-format-failed-with-error-1-android)

In the end I would like to bring your focus on the following points (may depend on the usage of Java 8?):

1) the appcompat_v7 project seems to be generated without the correct Android nature

2) the main project is generated with /libs/android-support-v4.jar included: in this post (http://stackoverflow.com/questions/24768869/adt-to-android-studio-unexpected-top-level-exception) they suggest to remove this jar in case a dependency from appcompat_v7 is used

3) why there are 2 Debug/Run "Android Application" menu items (see image attached)? Which one is correct?

Thank you
Vincenzo
Comment 12 Vincenzo Caselli CLA 2015-10-08 06:55:34 EDT
I can confirm that if I set Java 6 or Java 7 and corresponding Compilers level in Eclipse Preferences, then the only needed operation to fix is to Add the ADT nature to the appcompat_v7 project. Then it is possible to launch Debug/Run!

Instead with Java 8 it is not possible to launch the Run/Debug (see a couple of messages above for details).
Comment 13 Vincenzo Caselli CLA 2015-10-08 07:41:41 EDT
Created attachment 257157 [details]
Changes that fixes the appcompat_v7 project

Another info:
as I wrote before, making right click on appcompat_v7 project, 
Configure, Convert ADT Android configuration
is one needed step apparently.

This operation changes the nature from
- com.android.ide.eclipse.adt.AndroidNature
to
- org.eclipse.andmore.AndroidNature
along with others changes in .project from
- com.android.ide.eclipse.adt.*
to org.eclipse.andmore.*

see attachment.
HTH
Vincenzo
Comment 14 David Carver CLA 2015-10-08 09:47:37 EDT
(In reply to Vincenzo Caselli from comment #13)
> Created attachment 257157 [details]
> Changes that fixes the appcompat_v7 project
> 
> Another info:
> as I wrote before, making right click on appcompat_v7 project, 
> Configure, Convert ADT Android configuration
> is one needed step apparently.
> 
> This operation changes the nature from
> - com.android.ide.eclipse.adt.AndroidNature
> to
> - org.eclipse.andmore.AndroidNature
> along with others changes in .project from
> - com.android.ide.eclipse.adt.*
> to org.eclipse.andmore.*
> 
> see attachment.
> HTH
> Vincenzo

An easy way to fix these projects, is to Right click on the project, select Configure->Convert to Andmore Project

This will convert old ADT projects (which the Appcompat is) and update the necessary files to the Andmore natures and configuration.    

I'll open a seperate bug for automatically doing that conversion when importing the appcompat_v7 project.
Comment 15 David Carver CLA 2015-10-08 09:49:43 EDT
The reason you are seeing two Debug/Run options is that the old Motodev studio had it's own launch configuration.  This is part of the clean up that needs to happen to eliminate duplicate functionality when brought in ADT and MotoDev into one product.

I believe their is an existing bug for some of this work.
Comment 16 Vincenzo Caselli CLA 2015-10-08 11:20:54 EDT
Created attachment 257163 [details]
Configure menu sub items

Cannot see Configure->Convert to Andmore Project (see attachment), but only Configure->Convert ADT Android Configuration

Can you confirm that I followed the right steps in configuring the environment?
- Windows 8.1
- Java 8
- Eclipse Mars 1 JEE package
- Andmore Update site:  http://download.eclipse.org/andmore/milestone/0.5-M2/
- brand new workspace
Comment 17 David Carver CLA 2015-10-08 14:30:32 EDT
(In reply to Vincenzo Caselli from comment #16)
> Created attachment 257163 [details]
> Configure menu sub items
> 
> Cannot see Configure->Convert to Andmore Project (see attachment), but only
> Configure->Convert ADT Android Configuration

Java 7 should be the preferred environment.  Java 8 is an optional environment for some tooling vendors that needed it for their own tools.  A new project should default to java 7 when it is setup.


The Configure->Convert ADT Android Configuration

Is the option I was referring too.  That will convert an existing ADT configured project to use the correct natures that Andmore expects.


> 
> Can you confirm that I followed the right steps in configuring the
> environment?
> - Windows 8.1
> - Java 8
> - Eclipse Mars 1 JEE package
> - Andmore Update site:  http://download.eclipse.org/andmore/milestone/0.5-M2/
> - brand new workspace
Comment 18 Vincenzo Caselli CLA 2015-10-08 18:19:27 EDT
(In reply to David Carver from comment #17)
> Java 7 should be the preferred environment.  Java 8 is an optional
> environment for some tooling vendors that needed it for their own tools.  A
> new project should default to java 7 when it is setup.

Thank you David!

I'm not so convinced that Java 8 can be described in that way: it is the current version of Java after all and unless the Java auto update is not switched off in most cases it is the default setup.
But for now it can be ok. 
An Andmore adpter anyway should be aware about this current guideline.


> 
> 
> The Configure->Convert ADT Android Configuration
> 
> Is the option I was referring too.  That will convert an existing ADT
> configured project to use the correct natures that Andmore expects.

Ok, it works great!
I switched my current ADT project to Andmore with pleasure!
Comment 19 Doug Schaefer CLA 2016-01-01 21:23:25 EST
Sorry, I lost track of what is happening here. I ran into the same issue where New->Android project gives an NPE. I see below that Dave recommends removing that wizard. Is that what the plan is here? Is a pull request imminent or is this something I can do. It's a pretty bad experience.
Comment 20 David Carver CLA 2016-01-06 11:08:48 EST
This is probably related to:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=484566

My recommendation is to review the functionality of the Motodev wizards, and if they duplciate what the ADT provided, we go with the ADT wizards.  Sequoyah needs to be reviewed as well, and see if we need it still or can be removed eventually.
Comment 21 Stephen Blackwell CLA 2017-02-16 09:29:43 EST
The problem still exists with the current version of 0.5.1.201701251432 as of Feb '17.