I have created a build in ios successfully. Now i am trying to make build in android.
I have added android platform and imported this in eclise(ADT). I want to make configuration for android, as i am new to mobile application. I am unable to find any good reference for building android tutorial. I looked into getting started tutorial of phonegap but it was not much helpful
I assume you're using Cordova 3.0 and CLI
Proceed as following (some steps you might have already done, for completeness, I list them here anyway)
Open Eclipse ADT -> Window -> Android SDK Manager and make sure you have at least the 'Android SDK Tools', 'Android SDK Platform-tools' and at least on API installed.
Add the 'android sdk tools' and 'android sdk platform-tools' to your path.
In your cordova app (e.g. /myApp) folder, execute $cordova platform add android
Im assuming you have all your jscode correctly bundled in the /myApp/www folder, as you already have a working ios build. Otherwise, do so.
Plug in your Android Device or create and start a new AVD (In Eclipse: Window -> 'Android Virtual device manager').
execute $cordova prepare android
Open Eclipse and then File -> Import -> Android/Existing Code Into Workspace. In the opening 'Import Projects'-Window, select your /myApp/platforms/android as root directory. Depending on your workspace, you must select 'Copy projects into workspace', however your workspace would better already include the project, as this saves you from importing a new project after every $cordova prepare statement
In Eclipse: Run -> Run Configurations -> Target:: Enter Your settings depending on wether you use AVD or not.
On the bottom right: Run. Your app will be built and run.
Notes:
If you use mulitple platforms (e.g. android and ios), this way is more preferable than the way of user1306579, where you copy/hardlink your code directly in the /myApp/platforms/android/ folder, as you would have to do this for every platfrom equally and even worse: If you run $cordova prepare (or any command containg this, as $cordova run, $cordova build, ...) you would loose your changes.
Never edit JavaScript-Code directly in your /myApp/platforms/(anyplatform)/www/ folder. Always use /myApp/www/ and run $cordova prepare afterwards...
After step 5 you could use $cordova emulate android (for your avd) or cordova run android (real device), which would replace all other steps. However, if there are errors coming up, finding the reasons might be more difficult.
If your questions was over how to configurate the android app (platform merges, manifest configurations, ...) feel free to ask again :)
Regards, miweiss
I builded phonegap application with ant.
I think that this is not a big deal to build it with eclipse. You should copy web resources to the platforms/android/assets/www folder. Then you should use platforms/android as your project folder. I think you can use symbolic or hard links instead of copying to always refer to actual data.
Related
We are using eclipse luna 4.4.1, adb is installed on linux system to test android app. I followed below steps:
Import an android project in eclipse
Created libs folder in the android project and copied monkey talk agent into the libs folder(monkeytalk-agent-2.1.10.jar)
Right click on project and configured to Configur -> Convert to AspectJ Project
Right click on project and select AspectJ Tools -> Add to AspectJpath
Opened the AndroidManifest.xml and copied the below two lines in that xml file to give permission
Right click on the android project and navigated to project properties-> Java Build Path-> Order and Export tab -> checked AspectJ Runtime Library.
Right Click on project ->Run ->Android application.
After that I created a sample project in MonkeyTalkIDEProfessional
And then I created a sample test script in the project(Right click on project and navigated to New -> Script).
Clicked on android connection icon and selected the option(Android Emulator) option. In this case RECORD BUTTON of MonkeyTalkIDEProfessional is DISABLED.
This can be caused by several issues:
Port forwarding between your host maschine and emulator is not configured (read more on that). Run following command in order to fix that:
adb forward tcp:[PORT_NUMBER_IN_USE] tcp:[PORT_NUMBER_IN_USE]
The path to Android SDK in MonkeyTalk preferences is not set up correctly. You have to first install Android SDK and then specify path to it in MonkeyTalk. You should probably also check “Include Android Testing?” checkbox.
This tutorial for setting up Android agent in MonkeyTalk can also be useful to you.
while creating the MonkeyTalk project, it ask you for the instrumented APK. If it is accepting the APK means it is perfectly instrumented. Once it is done, make sure your phone connected to the system, better do
adb devices
If it is perfectly connected, your device should be visible in connect tab of MonekyTalk, select it, then open your Instrumented App on the phone, then the record button automatically appear in the MonkeyTalk. My suggestion is instead of using Emulator better to use Android device.
Steps:
Create a sample application "SampleApp" and add "android" environment to it.
Delete the "native" folder from the android environment. e.g. SampleApp/android/native
Right click on "android" folder and do - Run As -> Build Android Environment
Observe:
Following files are missing from the "native/libs" folder
android-async-http.jar
guava.jar
I didn't found any other way to include these files. On actual android device (Samsung Tab 3), "guava.jar" file is needed to initialize JSONStore object.
Update April 2nd, 2014: From the comments to this answer:
I have upgraded to Worklight 6.1.0.1. Now the issue is reproducible in
following scenario - 1. Instead of "native" folder, just delete these
2 files (android-async-http.jar, guava.jar) 2. rebuild the android
environment.
This is OK. The native folder is considered the user's domain. That means that if a user decides to remove parts of it - for example .jars from the lib\ folder, to maybe... reduce the app's filesize? that's okay. It is the user's responsibility.
I have tested this in Worklight 6.1.0.1; created a new project and application, added the Android environment, Run As > Run on Worklight Development Server.
The supposed missing files are in my android\native\libs folder:
I started with cordova and I have some small problems.
I've created an android application. I have installed java, android SDK , Apache Ant and Apache Ant.
I have added android with cordova add platforms android and builded correctly.
1 - When I use cordova run android I get the following error:
an error occured while running the android project . Buildfile : ...Demo \ platforms \ android \ build.xml . ERROR : Failed to install apk to device
I think this is due to the fact that my application is not in debug mode. How to set the debug mode? (' cordova emulate android ' works and launches the emulator )
2 - When I want to load a project in eclipse . (New project - > Android Project from Existing Code) I have the error:
Invalid project description Reason : . Invalid project description
How to overcome this error ?
3 - I want to install external plugins, eg
- https://github.com/ClickInnovate/CordovaPhoneGapPlugins/tree/master/Android/SocialMessage
- https://github.com/phonegap/phonegap-plugins/tree/master/Android/StatusBarNotification
It is said that to copy the java files in the src folder , but, I copy the java files in the original project or one that is build ( in plateform directorie )
If you run cordova run android -d, you will see additional debugging information printed to the console which should hopefully help you narrow down the problem. I've never seen that error you are getting, but to set your device up for debugging you should follow these steps. Some steps may be different or unneeded based on your Android device and version:
Settings --> Click on "About Tablet" --> Click on Build Number 7 times to activate "Developer mode"
Settings --> Developer options --> USB Debugging (make sure it is checked)
Settings -->Security-->Unknown Sources` (make sure it is checked)
Storage --> Click the drop down on the top right --> USB computer connection --> Make sure "Camera (PTP)" is checked
Please ensure that you are following the Android platform guide. If you are getting "Invalid project description" you might just need to type in a project description in one of the boxes in Eclipse? Another thing, make sure you are doing Import-->Android-->Android Project from Existing Code. Finally, it sounds like this might be a goofy Eclipse environment issue, here is another question on SO about this problem.
The plugins that you listed are old, they were made before Cordova 3.X came out. In 3.X, a new plugin management system using Cordova CLI and Plugman is used to install plugins - the only problem is that the plugins need to be updated to use this new format. You could look around to see if somebody has updated those plugins (look on the Fork page on GitHub is one good way.) Otherwise if you can't find an updated plugin, you could try to update the plugin yourself following the upgrade guides on the doc website. To answer your question, the java files would be need to eventually be copied into the build folder. In 3.X, the files are stored in the /plugins/ folder, then copied to the /platforms/android/ folder when you run cordova prepare, and are built into the cordova.jar when you do cordova compile. You can also read about how to install plugins with just plugman.
I've got a Phonegap/Cordova 3.0 app that I am testing on Android.
Since version 2.x, Cordova relies heavily on the command-line terminal. I've done all the setup stuff and I can build the app. But two things are troubling me.
First of all, an Android project has two www folders. One is [myproject]/www. The other is [myproject]/platforms/android/assets/www. I'm not sure which of these folders to edit when I am fixing bugs.
If I am correct, the first one is where you place your app files before using the command-line "cordova build" to create the app. The second one should then be only a copy that's used after building, before deploying.
Now my question is, when I make a change to my app and I want to test on device, do I have to use the command line to (re)build the app every time?
[myproject]/www is the directory in which you should put your source files. When you build your app these files are copied in to [myproject]/platforms/[platform]/assets/www. In addition to this, files in [myproject]/platforms/[platform] are also copied to [myproject]/platforms/[platform]/assets/www, which allows you to create per-platform overrides to your files.
Note that you should never edit files in [myproject]/platforms/[platform]/assets/www directly, as they will be deleted next time you build your project.
To run your project on your device use cordova run [platform], or to run it on an emulator use cordova emulate [platform].
I found a solution: in command-line terminal, type cordova run android and the app will be built, deployed and run on device.
Hi First thing : Edit www folder inside the asset folder.
Second : no need of command line build , you can take build via eclipse its very easy, Right click on project root folder --> Run As -> Android Application
The problem
I have a strange problem with SpringSource Tool Suite 2.9.1 Release and Subversive plugin, running on Windows 7 Home Premium x64. I'm trying to checkout an android project from an SVN repository.
Here's what I'm doing:
File > Import > SVN > Project From SVN
I fill in the path to my repository and check the HEAD revision
I click Finish
The project is found and the default option is Check out as a project with the name specified. I leave the name alone Set the Depth field to Recursively and again, select the HEAD revision.
I click Finish
A progress bar appears for a second just to show an error message:
Checkout operation for 'https://(.....)/Android' failed.
svn: Cannot create new file 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn\lock': System can not find the path specified
When I retry and follow the steps from 1 to 6, another dialog appears. It says:
This project already exists in the workspace
or there is a data folder in the checkout destination.
It allows me to select a folder to overwrite. When I do that, a similar but different error message is shown. It says:
Checkout operation for 'https://(...)/Android' failed.
0x0000000f: The folder 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn' is locked by some external process. Please unlock the folder and try to check out the project again.
What I've tried
First, I opened the SVN Lock view to see if there were any locks created by the IDE. There were none.
I restarted the computer, hoping it would solve the problem of any application locking the file but this does not seem to be the case.
After that, I created a new workspace in a different location and tried to check out the project in there. The result was the same.
Then, I attempted to change the version of SVN Kit. The situation persists in:
SVN Kit 1.2.3
SVN Kit 1.3.5
Native Java HL 1.5.4
Native Java HL 1.6.12
I thought that changing permissions to the directories of my workspace was worth giving a try. It didn't do the trick either.
Finally, I checked out the project in a different location, using Tortoise SVN and imported it into my workspace. I could run it (though some build path settings seemed to be missing) but it's not a solution. I can't possibly imagine working on the project simultaneously with a couple of people without the ability to commit/update/view history/resolve conflicts in my IDE.
I was advised to install a separate version of eclipse with its own set of tools and a different workspace for this application alone but it doesn't seem like a good idea. I'd like to keep it all in a single IDE. I'd also prefer to avoid reinstalling the whole thing as I don't feel like configuring all the other tools (mostly spring and android-related) from scratch.
Has anybody seen a situation like this? How can I get it working?
It's uncear to me whether this is a subversive problem or an SVN problem. I would try checking out from the command line (you must install SVN command line tools to do this, but I'd recommend having the tools around as a backup anyway).
Checkout from the command line and then import into STS using File -> Import -> Existing projects into workspace. Once in the workspace, you can select the project -> Team -> Share project to get svn support on it.
Rename the project and check out again , It must be a problem where u are trying to checkout the project which already exists with same name in the Package Explorer