Problem in android project conversion

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Problem in android project conversion

Postby marioxx79 » Mon Apr 07, 2008 3:14 pm

Hi all!!
I'm using this wonderful emulator to test my java application on it.

So...
this is my problem:
I've followed all instructions to use android with eclipse and i've installed the eclipse plugin as indicated in the instructions.
once i've loaded my java project in eclipse (a perfectly well working project) , i click on the project --> Android tools --> convert to Android project.
After this, in this project appears these 3 errors:

1. AndroidManifest.xml file missing!
2. The project was not built since its build path is incomplete. Cannot find the class file for java.awt.Component. 3. The type java.awt.Component cannot be resolved. It is indirectly referenced from required .class files

I'ev also tried to click to fix project properties (from android tools) with no results and then export application package but it fails to export.

Could you help me to solve this problem??
Thanks in advance!
Mario
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Top

Postby kiran » Tue Apr 08, 2008 4:49 am

Hi,
You have to create an android application to develop applications in android. Don't think java applications can be run directly in android emulator. AndroidManifest.xml file is required for all android projects and automatically created while creating a new android application using plugin in eclipse.
Regards,
Kiran.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby marioxx79 » Tue Apr 08, 2008 12:58 pm

kiran wrote:Hi,
You have to create an android application to develop applications in android. Don't think java applications can be run directly in android emulator. AndroidManifest.xml file is required for all android projects and automatically created while creating a new android application using plugin in eclipse.
Regards,
Kiran.


Uhm...so you're saying to me that if i have a java-written project of 1,000,000 lines code, i have to re-write all the project in a format compatible with android???
It sounds strange...where's the portability???
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby Jesmiatka » Tue Apr 08, 2008 1:30 pm

You do know that Androids applications are runned by activities and services? I do not think your 1 million line Java application includes activities.
If you have a well written Java app you should only have to port your controller and view part of your code so it fits on Android. Which means your model (domain) still would be in tact and should be able to remain unchanged.
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby marioxx79 » Tue Apr 22, 2008 3:02 pm

Jesmiatka wrote:You do know that Androids applications are runned by activities and services? I do not think your 1 million line Java application includes activities.
If you have a well written Java app you should only have to port your controller and view part of your code so it fits on Android. Which means your model (domain) still would be in tact and should be able to remain unchanged.



Hi Jemiatka,
thx first of all for your tips. Unfortunately i've just seen your message here on the forum. I was able to convert a java project in an android project but the only problem i had is that the famous AndroidManifest.xml is missing. I've tried to copy an androidmanifest.xml file from a sample to my new project (converted from java).
So...does exist any tool to build this file from the scratch? I've tried also to edit by hand but i've received an error about the package name...
Could u help me?
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby Jesmiatka » Tue Apr 22, 2008 3:32 pm

Hi,

the manifest declares a package which the R class will be generated in.
You define this in the outer tag of the manifest.
Example given below

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.    package="nl.eid.mobile">
  4.  
  5.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


a complete manifest with only 1 activity (Start.java) should look something like the following:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nl.eid.mobile">
  4.  
  5.         <application android:icon="@drawable/icon" android:label="Mobile">
  6.  
  7.                 <activity android:name=".Start" android:label="@string/app_name">
  8.  
  9.                         <intent-filter>
  10.  
  11.                                 <action android:name="android.intent.action.MAIN" />
  12.  
  13.                                 <category android:name="android.intent.category.LAUNCHER" />
  14.  
  15.                         </intent-filter>
  16.  
  17.                 </activity>
  18.  
  19.         </application>
  20.  
  21. </manifest>
  22.  
  23.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Adding an additional activity can be done by the tool or by adding the following line:
(Activity class is Login.java and is placed in the package defined in the beginning of the XML)

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                 <activity android:name="Login" android:label="Login with your information" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Hope this will help you a little bit!

Yours sincerely,
Mike
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Top

Postby marioxx79 » Tue Apr 22, 2008 10:29 pm

Jesmiatka wrote:Hi,

the manifest declares a package which the R class will be generated in.
You define this in the outer tag of the manifest.
Example given below

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2.    package="nl.eid.mobile">
  3.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


a complete manifest with only 1 activity (Start.java) should look something like the following:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nl.eid.mobile">
  3.         <application android:icon="@drawable/icon" android:label="Mobile">
  4.                 <activity android:name=".Start" android:label="@string/app_name">
  5.                         <intent-filter>
  6.                                 <action android:name="android.intent.action.MAIN" />
  7.                                 <category android:name="android.intent.category.LAUNCHER" />
  8.                         </intent-filter>
  9.                 </activity>
  10.         </application>
  11. </manifest>
  12.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Adding an additional activity can be done by the tool or by adding the following line:
(Activity class is Login.java and is placed in the package defined in the beginning of the XML)

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                 <activity android:name="Login" android:label="Login with your information" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Hope this will help you a little bit!

Yours sincerely,
Mike



Your help is really precious mike...
i think i need just some little tricks in order to solve my problems.
I've solved the problem related to the name of the package but...
Suppose i've my java project in a package called my_project.
This project is made by a lot of classes and in one of these (suppose my_main) there's the main function.
Now i've changed the androidmanifest.xml file in order to point to my_main function. But after this...all my classes are changed in : my_main.myclass1 , my_main.myclass2 , my_main.myclass3 and so on.
My suspect is that i have to manage this two lines in the xml file
<action android:name="android.intent.action.MAIN"
<category android:name="android.intent.category.LAUNCHER" />
in order to let xml to point to the right project.
Have u any idea to suggest to me?
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby Jesmiatka » Wed Apr 23, 2008 7:56 am

Hi,

the following XML is used for selecting the activity that will be launched when you start up the application, so it's only needed in 1 activity.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <action android:name="android.intent.action.MAIN" />
  2.  
  3. <category android:name="android.intent.category.LAUNCHER" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


You are only gonna define the classes that extend from Activity in the manifest.xml. These classes (most of the time) have interaction with the phone UI.
Go and check out http://code.google.com/android/devel/bb ... ifest.html if you want more information about the manifest.

Yours sincerely,
Mike
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby marioxx79 » Wed Apr 23, 2008 8:42 am

Jesmiatka wrote:Hi,

the following XML is used for selecting the activity that will be launched when you start up the application, so it's only needed in 1 activity.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <action android:name="android.intent.action.MAIN" />
  2. <category android:name="android.intent.category.LAUNCHER" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


You are only gonna define the classes that extend from Activity in the manifest.xml. These classes (most of the time) have interaction with the phone UI.
Go and check out http://code.google.com/android/devel/bb ... ifest.html if you want more information about the manifest.

Yours sincerely,
Mike


Hi mike,
thx again for your interesting.
Are the "action android" and "category android" usable to start a java application on mine?
I'm using the android emulator on eclipse and i imagine to create a sort of button on android desktop pushing that, my java application starts (calling tha main function of my java application). Is it possible according to you?
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

On launching ext apps again :-(

Postby marioxx79 » Mon Apr 28, 2008 10:27 am

I'll try to explain better...
I've a java program called my_program with a lot of packages and classes.
In one of these class (let's say class_one) there's the main function of the program.
Is there a simple way to call the main function inside the class_one (in order to start my java application) from android?

Thx in advance for your explanations!!
Regards
Mario
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby Jesmiatka » Mon Apr 28, 2008 10:32 am

Just instantiate it in an activity?
I have no idea what your java application does. If it only passes around Strings, ints, objects then it can be easily done this way (can't it?). If your Java app handles some other type of UI things which are not Android based it will give you errors for sure.
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby marioxx79 » Mon Apr 28, 2008 11:09 am

Jesmiatka wrote:Just instantiate it in an activity?
I have no idea what your java application does. If it only passes around Strings, ints, objects then it can be easily done this way (can't it?). If your Java app handles some other type of UI things which are not Android based it will give you errors for sure.


Thx for your response !
So...my java application is an implementation of an ims client. (Ip multimedia subsystem).
Because of this application run on my pc, i've thought this would be an occasion to load it on a pda with android. But loading it on the android emulator it won't start!
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby marioxx79 » Mon Apr 28, 2008 1:47 pm

do you think that an application as a sip-phone is too rich of functions to be implemented as an android application?
Isn't there a way to simply call the main function of my application by android emulator?
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby marioxx79 » Mon Apr 28, 2008 4:54 pm

Hi jemiatka!!!
I've some news...
i've been able to rename all classes in order to start my application from android (PROBABLY)
NOW...i've no more errors in the project but when i try to launch this application as an ANDROID APPLICATION
i've the error: "could not find /bin/Graphic.apk"
where Graphic is the project's name.

Could u help me to solve thsi problem? Is it possible to build manually this apk file?
thx in advance
regards
mario
marioxx79
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Apr 07, 2008 3:04 pm

Postby Jesmiatka » Tue Apr 29, 2008 7:54 am

Yeah you can build the APK manually.

You should do the following:
Right click your project -> Android Tools -> Export application package

Good luck :D
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Top
Next

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 3 guests