Programmatically creating cordova/ionic apps - java

I have a development environment where web apps can be hosted. We generally use angular for our web apps so ionic should already be a pretty close match.
What I'm looking for is a way to be able to take a web application in angular and basically "generate" the ionic app out of it. We can assume that the app has been "modified" to correctly import the ionic module(s) and the necessary code.
Other than that, the site must remain functional on a desktop client (but I assume this is not an issue) and we want to "generate" the apk (or whatever target environment is required) based on the original web app.
Ideally the generation should be triggered by basically right clicking in a menu and selecting "Generate APK". This means I'm looking for programmatic access to whatever API cordova/ionic has.
My google-fu is letting me down though because all I can find though is command line references, I would prefer to stay away from commandline-level integration unless absolutely required. Other than that any search for API just brings up the javascript API they expose, not any API they might expose to programmatically generate artifacts like an APK.
UPDATE: I don't mind a downvote (the question is rather hard to phrase correctly) but at least state why so I can improve upon it.

Building a native APK in command line should be possible using the Android Gradle toolchain. You can go thru the process in the IDE and then just replace the files for your created app with the newly generated files and invoke gradle. For other OS's this becomes harder e.g. for iOS using xcodebuild is pretty hairy and if you add into it complexities like hosting Macs in the cloud (required for xcode) and the changes Apple makes all the time...
We implemented pretty much that (and a lot more) for Java at Codename One, we also support including Cordova plugins which might work for you. We also provide white label services for 3rd parties.

Related

Android App in-place update

I have an application which is deployed to some pretty remote, data connection starved regions of the world, specifically to health workers.
These people have minimal data connections and the app requires regular updates to provide increased functionality and critical bugfixes.
The problem we have is that the APK for the app is 5.7mb and only going to get larger. Which means that every time the users need to update the app, they have to download the 5.7 meg apk to update. If we roll out more than one release in a week, it can eat through a significant portion of their data plan as well as time as they have to sit and wait for it to download and install.
Is there a better way to do this? Some way to patch the versus completely replacing the application on the host device so that we deploy smaller patches?
I've tried looking for examples of "host" applications, where the actual application is just a shell for a downloadable set of libraries, sort of like a plugin system, but couldn't find any examples.
Are there any resources or a standardised way to accomplish this?
Also worth noting this is a react-native app and we're already running proguard and splitting apks based on architecture to reduce the apk size.
Did you have chance to examine CodePush? It basically allows you to push updates only for javascript part (the bundle) of your app, on-the-fly, without making your users download a new version of the apk.
If you add new native code to your project, you will still need to build and release a new apk though.
How it works is that, when you update the javascript code in your app, you push a new release. When users run the application, CodePush checks if there is a new version available and if there is, update it immediately and restart the app if you mark the mentioned release as mandatory or use the newly downloaded bundle version on next run.
Edit: react-native library of CodePush is here on github.

Android Policy: External application files

Google Play Developer Program Policies says:
An app downloaded from Google Play may not modify, replace or update
its own APK binary code using any method other than Google Play's
update mechanism.
I want to publish my application to Google Play. And I been planing to load my core SWF file dynamically, so game updates could be done without the need of going to Google Play market. An alternative Java implementation can achieve the same thing by downloading remote jar file.
In both cases I will have the next limitations:
I cannot modify my Manifest file.
I cannot extend the application permissions that I asked
My external code is bounded to application sand box(Just as the rest of my application)
Notice that my external code is not part of the APK files. It will be stored in application folder or in external storage(SD-Card). Its same place where external assets is stored.
Does this violatating Google policy? I am not sure what they meant by "APK binary code".
I am not a lawyer, and I don't play one on TV...
Your best course of action is to look at the reason they included that phrase in the first place. That text now exists in the Google Play policy because Facebook did the very same thing that you are describing in their application (providing an auto-update mechanism outside the Play Store) earlier this year, and Google threatened banning the application until this "feature" was removed (which it was, shortly thereafter).
The spirit of the law in this case is that Google does not want applications updating themselves without the user's consent outside of the Play Store...period. If your application does this, you can bet Google won't care how you are doing it and will likely remove the application when and if the feature is discovered. They won't care how closely executable code in an external SWF file resembles the internal classes of the APK.
Legal language like this is is intentionally vague so companies can apply it in any situation they see fit. Don't think you're being safe by splitting hairs with the terminology.
I am not a lawyer. I see this restriction as limiting only the apk binaries. There are many apps that have dynamic behavior changes, for example Google search where the search results algorithm is determined by dynamic code on the server, or facebook which loads new images texts, layouts and more.
I think that as long as you do not do anything bad for users using the swf changes, you should be ok.
The purpose of this clause, as I understand it, is to prevent apps from loading and using code that was not tested by Google using the normal process that tests apps when published. Google want to ensure that all code is scanned/tested by their bots.

How do I connect my Desktop Java Application to an Existing GAE Datastore?

Currently I have a very basic desktop Java application in Eclipse that is meant to add entities to an existing project's datastore on Google App Engine. I have it all setup right now but since I am new to working with Google App Engine, I have no clue on how to get the application to send the Entities into the datastore of my existing project.
I tried looking this up online but most of what I found was for making java web apps. My goal is to have the application running as its own application, not through a browser.
So, what do I have to do to make the application connect to my GAE datastore? Is there some code I need to type, or perhaps some xml file I need to have within the project? I am just using the Java Eclipse plugin for Google App Engine.
Thanks for the help!
Based on the language of your question, I think you really need a big-picture sort of answer, rather than any specific code. Therefore:
You have a desktop application. This runs on some desktop computer.
You have a Google App Engine application with its data store. This runs in Google's data centers.
These are not the same computer. Therefore, they must communicate over the network in some fashion — that is the missing piece you're looking for.
Since GAE is designed around doing web applications, I recommend you think of this as a “web service” situation — that is, your desktop application makes HTTP requests to your GAE application. (The situation is simplified over the general case because you are writing both the client and the server.)
I recommend you read about designing simple web services and do whatever seems to fit your application.
One important warning: Unless your GAE application only ever has one user, you must not simply write a bridge that gives access to the data store over HTTP, because then anyone can make arbitrary changes to other people's data. As it is said for multiplayer game design: don't trust the client — that is, only accept network requests that make sense according to the rules of your application, and do not expect the client to enforce those rules. This is because anyone can make requests to your GAE application using something other than your desktop application, so you must assume you could receive arbitrary requests. This is the fundamental nature of the Internet.
For example, in the simple case of a multi-user application whose users do not interact with each other using the application, this means that every request that, say, updates a record, should only update a record which belongs to the logged-in user, not one of any other user.
For anyone that gets this problem in the future, I got an answer to it. I just tried experimenting around with the project settings and found it. So as it turns out, after you have installed the GAE Eclipse Plugin, you can just right click your project folder in the Package Explorer, go the Google sub menu, then click on App Engine Settings... .
From there, you need to check the Use Google App Engine checkbox, then in the deployment section, just fill in your project's Application ID. Your project's application ID can be found under the Application Settings tab of your project's online Google app engine dashboard. It is listed there as your Application Identifier.
Turns out that for me, I will need to find a different solution as you cannot integrate GAE with a desktop application that uses the Java Swing library. Bummer :/

Build Android native library with Adobe Air

I'm currently working on an Android application built with Adobe Air sdk, in AS3. I was wondering if it's possible to compile a kind of UI library that I can import in a Android native application (Java). Basically, I would like to build my UI with Adobe Air, but the main part of my application with Java, the native way.
What I have in mind is to convert the adobe air-generated APK into a Jar file I would import in the native application project, and call some functions that display something on the Screen.
Is it possible? I think it may be possible, because when I don't import Adobe Air SDK in the application, I must install Adobe Air application with the Play Store to make my application working. I don't find lot of things on Google about that :s.
Thank you for your help.
Yes it can be done (in theory), but hold on to your hat, it's a bumpy ride!
I see it is a very old question, with a new bounty (the questioner has not logged on for 3 years!), but here we go...
This method goes to the heart of how android java apps are constructed and run (i.e. DEX, so it will work with adobe-air or ANYTHING, it is fundamental [general method]). (by the way you use the word native in a confusing way, native is commonly understood to mean the JNI (c++) library element of an app).
You say:
"What I have in mind is to convert the adobe air-generated APK into a
Jar file I would import in the native application project, and call
some functions that display something on the Screen."
Android programs are compiled into .dex (Dalvik Executable)[now called ART but binary compatible] files,
which are in turn zipped into a single .apk file on the device (with other things like the manifest and resources). (unzip a .apk and look inside).
A .jar file contains DEX files (zipped). (unzip a compiled .jar and look inside).
I have done some work like this before, here's a link to a tutorial and coding examples [tested by me] (in android studio + gradle) [custom build elements are usually needed (I also give an ant example)].
See my stack-overflow answer Dynamic loading of DEX files
This in theory answers your question, but it's fundamental stuff, complex and has limitations that make it hard to code and maintain (resources are a real pain in the a**e).
Question: This all seems very complicated and hard !
Yes it is ! It is an increadably silly an difficult thing to do! That is why we invented cross platform frameworks, (and for web based code javascript/css/html5...). Failing that PORT the code.
I'm more of a Flash/AS3 coder than Java so can't give you a full answer but...
A better approach might be to just render your SWF-based User Interface itself via Java code (as opposed to compiling SWF into APK format then trying to embed Flash APK inside Android APK).
This way your SWF can also communicate with Java functions (via AS3's external Interface class). Making it easier to trigger Java functions when a button on the SWF U.I is pressed etc..
You just have to find an SWF render library for Java.
Maybe check out SWFTools. Particularly the SWF Class looks promising. I have not tested this library but it might help you.
I am not a Adobe AIR developer at all, however, I have developed a few Android App with both native environment and with some kind of framework (specifically PhoneGap). So, may this can help you.
I don't think that there would be any tool which could directly convert mobile apps build using frameworks like Adobe AIR, PhoneGap or any other HTML5 based framework to a native Android app because technically it is very difficult and unfeasible to do a proper mapping between each and every element of HTML5 (or Flex element in your case) to a corresponding native control or logic. The best you can do is use plugin mechanism provided by your framework to interact with Java and vice-versa and basically that is why the framework is there. For most of HTML5 based frameworks there is a plugin mechanism which allows developer to interact with native functionality (like Background Services, Activity or any other native resource). Even these frameworks are build using the same modular or plugin based approach and there major functionality (accessing Camera, Audio, SD Card etc native resources) works like this. We have to enable that feature before using that in our app.
So, look for plugin type of mechanism in Adobe AIR.
Hope this helps.
Maybe this is a dirty way to help you, but you can :
Install the adobe air program in one computer
Copy the files of the install folder of the adobe air program
Embed all this files in the java application
Install the java application
Save the adobe air files in one folder
Start the adobe air with java (like you will do it with the console, a simple call to YourAirApp.exe)

GWT integration with PhoneGap

Edit - I know there are similar questions to this on SO, but I feel my specific questions are not duplicates at all. If you disagree with me please bring them to my attention before downnvoting or closevoting! If you can prove to me that my question is a true duplicate I will delete this question myself!
My understanding of the GWT is that it provides an SDK and API that allows you to code in Java, and it generates all the client-side HTML, CSS and JavaScript required to run a full-fledged web (or mobile web) app.
My understanding of PhoneGap is that it allows you to code against its JavaScript API and, through configuration, allows you to tell it which native mobile platforms (Android, iOS, Windows Phone, etc.) it should create nativee wrappers for. Hence you "write once, run many" with it, turning your JavaScript code into a native Android app, native iOS app, etc.
If these two assumption are incorrect, please begin by correcting me! And, if there are any caveats to these assumptions, please let me know!
Assuming my understanding on GWT and PhoneGap are more or less correct, I want to try and use them together for an app that would be available as (1) a web app, (2) a mobile web app, (3) an Android app and (4) as an iOS app.
I want to "daisy-chain" these two in my Ant build, whereby my pure Java code is converted (via GWT) into JavaScript (that complies to the PhoneGap API), and then a second build process uses PhoneGap to create and deploy:
A Java WAR (web and mobile web app)
An Android APK
An iOS binary (I believe this is an IPA file, but I may be wrong)
So with those as the "givens", here are my questions:
Is this possible? If not, why? Any way to hack- or juryrig-together a solution that forces this to work?
I've noticed something called gwt-phonegap - will I need this in order for my proposed solution to work, or would this library just be a "nice to have"? Why or why not?
Any other considerations I am not thinking of here? Other libraries or tools that would behoove me?
Note: I have heard (but am not asserting!) that Titanium is superior to PhoneGap. Titanium, however, is not free. And I am quite broke. Thanks in advance for any help here!
There is an open source project out there combining GWT & Phonegap to build mobile apps:
mgwt - http://www.m-gwt.com
There are many people out there using it to build mobile apps and there is quite a lot on documentation including videos there, especially this one:
http://www.youtube.com/watch?v=0V0CdhMFiao&feature=plcp

Categories

Resources