Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Sunday, March 18, 2012

Problems with a href tag and window.location in phonegap application

I was using <a href> tag and window.location for links in the pages.But it was displaying the old page itself. 
PhoneGap gets notified whenever a new page is to be loaded.  However, there is a problem in Phonegap (phonegap-1.0.0rc2 and older versions) in using a <a href> tag or window.location.
As a result, PhoneGap doesn't have any way to intercept the request.So it continues to display old page or it will not be able to handle the parameters passed from previous page.
Code with problems:
<a href="HomePage.html">Home</a>
and
window.location="HomePage.html";
Solution: 
1) Use navigator.app.loadUrl(file:///android_asset/HomePage.html); instead of 
window.location or <a href tag.
2) Try to make use of same page with sections (<div> tag) than having code written
over multiple page.

Monday, January 9, 2012

"Project has no default.properties file! Edit the project properties to set one."error on adding existing phonegap project into workspace

I was facing the this issue  when i tried to add an existing Phonegap project into another workspace.
Reason:
Android Tools automatically generate the file default.properties which tells about target API level.
But when the project is added into the another workspace this file does not gets created.
Resolution:
Create a properties file default.properties directly under the Phonegap project directory.
Mention the target API level in it.
(ex: If the target API that you want to use is 8,then add the following code in the default.properties file)
 target=android-8

Tuesday, January 3, 2012

How to resolve Conversion to Dalvik format failed with error 1 in Phonegap project?



Project shows this error because the phonegap jar (phonegap-1.0.0rc2.jar) /any other jar  file is not stored in the proper folder in the project setup.
I have created a Lib folder under src folder and placed the phonegap  jar into it and added the jar to buildpath which resulted in the error.


Resolution:
1) Remove the Phonegap jar/any other jar from the build path.
In the eclipse select project -> Properties ->Java Build Path.Select the tab libraries.Then select the phonegap jar and remove it.
2) Add the lib folder directly under the project(i.e not under any folders in project) and
 place the phonegap jar under it. Add the phonegap jar  to build path.
Then Clean and build the project.



Sample Exception stracktrace
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/phonegap/AccelListener;
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.dx.command.dexer.Main.run(Main.java:206)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at java.lang.reflect.Method.invoke(Unknown Source)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:179)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:585)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:490)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2012-01-03 18:57:54 - MedicalSalesManApplication] Dx 1 error; aborting
[2012-01-03 18:57:54 - MedicalSalesManApplication] Conversion to Dalvik format failed with error 1
[2012-01-03 18:58:45 - MedicalSalesManApplication] Dx

Sunday, November 27, 2011

AndroidManifest.xml has the error "No resource found that matches the given name (at 'icon' with value '@drawable/icon')." for the application tag.

AndroidManifest.xml has the error "No resource found that matches the given name (at 'icon' with value '@drawable/icon')." for the application tag (highlighted in red color below)

<application
 android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".FirstAppsActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

I have faced the issue for multiple times. I have found 2 reasons for this error.
1) icon.png is not present in the drawable-hdpi folder inside res folder of Android project.
2) Android application is not able to find the icon.png file.

Solution

1) Make sure that icon.png (or whatever files mentioned in the <application android:icon tag) is present in the drawable-hdpi folder inside res folder of Android project.

2)If it shows the error even if the icon.png is present,then remove the statement <application android:icon from the AndroidManifest.xml and add it again.

Resolve "Target runtime Apache Tomcat v6.0 is not defined." error

Go to window ->preferences ->Server->Runtime environments . add server Apache Tomcat v6.0 Mention the directory where apache-toma...