cancel
Showing results for 
Search instead for 
Did you mean: 

SMP3: Android Cordova project won't compile in Eclipse(Kepler)+ADT, why?

Former Member
0 Kudos

Hi SMP Kapsel experts,

I am stacked in a problem and hope soemone can help me out. Basically, I just want to create a Cordova project (and add Kapsel plugins later) and load it into Eclipse (Kepler)+ADT, and run it on AVD or HTC devices

Here are my settings of tools:

  IDE: Eclipse (Kepler SR2) +ADT (23.0.4.1468518)

  Android SDK  (upto anroid 5.0.1)

  Cordova (4.4.2)

  jdk1.8.0_31

  SMP server: SMP3.0_SP05

  SMP SDK (Kapsel SDK): 3.0_SP06_PL02

Here are the commands used to create a cordova project:

  cordova create appFolder com.myapp.id myapp

  cordova plateform add android

  cordova build android     //this is optional, tried in same cases

  cordova prepare andriod

Here is the problem:

(Note that for now I have not reach the step to add Kapsel plugin yet. ) After these, I load the generated project into the Kepler eclipse, its precompipling shows this error:

Can anyone please tell what might go wrong here? Seems cordova lib is missing but why? Some version mismatch?

Thanks a lot in advance!

Dong Zhu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi There,

Thanks for all the help tips, and those steps are correct steps to follow.

Here I want to share the solution of my specific issue:

Cause: used cordova 4.2.0 which has bugs - does not create correct 2 projects. There is a note how to manually modify teh generated .xml files to get the project work.

Better solution is:

Fix:  - installed cordova 3.6.3 which generated 2 projects.

By default, the latest codova is installed - which you should be careful - the latest does not mean the best!

Br,

Dong

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Abaper and Midhun,

Thanks a lot for the info. I will post the question somewhere else.

At least I am using different versions: cordova 4.2.0, android API 19. I will try other versions.

Br,


Dong

Former Member
0 Kudos

Hi all,

I have found two things that might be wrong:

1. When importing the cordova project into ADT, I didn't use "Android Project".

2. The default JRE in ADT was pointing to an old jre.

But after the fixes above, I have the following issues:

1. After generate a cordova project, when Import it into ADT, there are 2 projects to be imported:

    One is my project, the other is called "Cordovaapp-CordovaLib". Is this correct?

2. After loaded into ADT, I still have issues in my cordova project:

    The same error as shown in my pic above - the building cannot see teh package src/org apache.codova which is in "Cordovaapp-CordovaLib" project.

   I think this is the key issue - the cordova package is missing in my generated project.

3. In CordovaApp.java where the errors ocurr, its code:

public  class CordovaApp extends CordovaActivity{

    @Override

    public void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);

         super.init();

         // Set by <content src="index.html" /> in config.xml

         loadUrl(launchUrl);


Here, besides the error due to missing package, my question here is how can I set the var "launchUrl" to point to the index.html under /www/ folder? I cannot see here this string is defined. Could it be defined in the missing cordova package? By hacking the err code (ignoring), II can get the cordova icon shown in the Android emulator, but no actual index.html UI is shown.

Appreciate all the helps!

Dong

midhun_vp
Active Contributor
0 Kudos

Hi Dong,

Are you following the below steps:

  • To open the corresponding project in Eclipse, click on File > New > Other.

  • Expand Android folder and choose “Android project from Existing Code” and click Next.

  • Browse to IATDemo\Platforms\android folder and click Finish. Note: Do not check the option “Copy projects into workspace”.

Regards, Midhun

SAP Technology RIG

Former Member
0 Kudos

Hi Midhun,

Yes, I did the same steps as yours and I did get the similar pic above. The "Copy project into workspace" was unchecked by default. After that, there are two projects imported into ADT.

In fact, what I wonder is the further steps done in the IDE (Kepler+ADT):

Can you show me how your prject looks after the import? I can see in your pic that there are also two projects to be imported. How did you build your two project? - Did you merge them into one or keep them separated? The cordova lib is in fact in the "CordovaLib" project.

Anther thing is how you resolve the "launchUrl" variable in the onCreate()?

Thx a lot!

Dong

Former Member
0 Kudos

It simple, just add cordova liblary into your java build path.

Former Member
0 Kudos

Hi Abaper,

Thanks for your reply.

I checked the project folder, but there is no cordovalib.jar found. Could you show me whcih commands you used, and which version of cordova, jdk you use. Thx.

Br,

Dong

Former Member
0 Kudos

First, please do the steps that told here; http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-Line%20Interface and then import the project into eclipse as midhun told, then you will see cordova lib.

midhun_vp
Active Contributor
0 Kudos

Hi Dong,

Below is the screen shot after import:

I haven't merged IATDemo-CordovaLib. The project was build automatically and I am able to run the IATDemo project.

I have Java 7, cordova 3 and android API level 21.

I would recommend to post this question in stackoverflow for a quick response since it is not related to SAP's technology/solution. And you can come back if you stuck with Kapsel.

Regards, Midhun

SAP Technology RIG

midhun_vp
Active Contributor
0 Kudos

Hi Dong,

When you are importing the project to Eclipse do not check the option "copy projects into workspace" and try.

I have noticed that cordova version you are using is incompatible with SMP SDK (Even it's not the reason of the issue; would help you later). You can refer:

Cordova 3.0.6 (or the latest 3.0.x version) should be used if using SMP 3.0 SDK.
Cordova 3.1.0-0.2.0 (or the latest 3.1.x version) should be used if using SMP 3.0 SP01 SDK.
Cordova 3.3.1-0.1.2 (or the latest 3.3.x version) should be used if using SMP 3.0 SP02 SDK.
Cordova 3.4.0-0.1.3 should be used if using SMP 3.0 SP03 SDK.
Cordova 3.4.1-0.1.0 should be used if using SMP 3.0 SP04 SDK.

Cordova 3.5.0-0.2.7 (or the latest 3.5.x version) should be used if using SMP 3.0 SP05 SDK.

Cordova 3.6.3-0.2.13 (or the latest 3.6.x version) should be used if using SMP 3.0 SP05 PL03 or SP06 SDK.

Reference:

Regards, Midhun

SAP Technology RIG

Former Member
0 Kudos

Hi Midhun,

Thanks for the quick reply. You hit some of the points - first, I will try the import process again. Secondly, I also notcied that there are different versions between Cordova and SMP SDK. From the posts I saw, they are using old Cordova versions. Is there any link which shows the complete list of the versions used?

But just for now, I have not reach the step to add the Kapsel plugins using the Cordova. All I tried was a purely cordova project which was imported into Eclipse ADT. It should not be related to SMP SDK yet.I had an old project I made before which was working and I can see there is a cordovaxxx.jar in the project tree.

Seems smething to do with "Build Path" config in Eclipse where cordova lib has to be added somehow. Thx.

Br,

Dong

midhun_vp
Active Contributor
0 Kudos

Hi Dong,

I have faced a similar issue, try the solution I given.

You can always refer to the link I provided in my previous comment , which is regularly updated by one of our Kapsel expert.

Regards, Midhun

SAP Technology RIG

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

You should run cordova platform add android not what you had tried

cordova plateform add android


Meanwhile, should check

Former Member
0 Kudos

Hi Jitendra,

Thanks a lot for quick reply.

Sorry, it was my typo - I did use cordova platform add android

I guess something else wrong. Thx.

Dong