Meteor cordova build - how to deploy to device? - android

I have been reading https://meteor.hackpad.com/Getting-Started-With-Cordova-Z5n6zkVB1xq#:h=Device-Setup and the docs on how to deploy a cordova app are a bit lacking, as to be expected with very new functionality! I execute: meteor build <bundle path> -p <host>:<port> which has built my app, I have a tarball for the server and an /android folder which contains an AndroidManifest.xml and all sorts of other files - I assume I need to compile this into an APK.
Is this correct? Can someone point me in the right direction? Thanks!

Inside "bundle path"/android you will find you apks already compiled.

Related

Moodle Mobile 3.7.0

After downloading Moodle Mobile2 from github at https://github.com/moodlehq/moodlemobile2 so now its a zip file on my computer. In simple steps how do i get to publish this on googleplay?
I have tried renaming the zipfile to .apk then used advanced apktool to sign and recompile but when uploading to google play i get:-
Upload failed
Your APK cannot be analyzed using aapt. Error output:
Failed to run aapt dump badging:
ERROR: dump failed because no AndroidManifest.xml found
Obviously things are not so simple. If someone can help me with some basic steps from zip file to apk and publish i would be grateful as i am trying to self learn the process but need some help.
Thanks guys
It is definitely not so simple as to download the repository :) The detailed steps (from 1 to 9) are listed in the official documentation here: https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2
Summarizing the documentation and from my own experience you need to:
Install all building tools dependencies, at the time I'm writing this (Aug '19) those are: node v8.12.x or v11.12.x, cordova 8.1.2, ionic, gulp
Install additional tools for MacOSX or Windows if you are using any of those SOs (see doc page linked above).
Clone the repository with git clone or unzip it after downloading the zipped repository
To prepare the iOS and Android platforms (that allows you to build the binaries later on) go inside your project folder (unzipped or cloned folder) and run (from a terminal):
$ npm install
$ cordova prepare
$ gulp
Resolve any compatibility issues among packages that may have arised.
Apply the npm packages fixes to build for production with AOT listed in step 9 of the documentation page I linked above.
Build the apk from the terminal:
$ npm run ionic:build -- --prod
$ cordova build android --release
At this point you will have the compiled apk ready to be signed and uploaded to the Google Store.

How to build a release version of react-native Examples

Now, I can install debug version of react-native examples on my Phone.
follow these steps:
./gradlew :Examples:UIExplorer:android:app:installDebug
./packager/packager.sh
But I have to start the server for the app to run correctly.
I want to bundle the js-bundle file to apk and install a release version on my phone.
And I can demonstrate it to my friends anywhere.
Can anybody help me?
Thank you in advance for your kind help or some hints.
First, you need to sign your apk file and add a release build type to your gradle config following the instructions in the documentation
Then, run you packager with ./packager/packager.sh or simply npm start.
The next step is to download the js bundle to the android assets directory. Because there is no react.gradle file this needs to be done manually - source:
curl "http://localhost:8081/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android&dev=false" -o "Examples/UIExplorer/android/app/src/main/assets/UIExplorerApp.android.bundle"
Finally, you can run the installRelease gradle task (or assembleRelease and then install the apk manually).
Update on pianiel's answer: The curl command is now
curl "http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=false" -o "Examples/UIExplorer/android/app/src/main/assets/UIExplorerApp.android.bundle"
because of changes made to UIExplorer's project structure.

How do I put my cordova application on the android play store?

If there is official cordova documentation for this, I couldn't find it and would appreciate a link. I have run cordova run android to deploy to my phone. Things look good. Now I'm ready to turn this into an official app that users can download on the android play store? When I build my app it generates a file named "CordovaApp-debug.apk". That "debug" part makes me think this is the wrong file to work with, but I'm not sure how to generate the right file.
Deploying a hybrid app to the Google Play Store
These steps would work for Cordova, PhoneGap or Ionic. The only difference would be, wherever a call to cordova is placed, replace it with phonegap or ionic, for your particular scenario.
Once you are done with the development and are ready to deploy, follow these steps:
Open a command line window (Terminal on macOS and Linux OR Command Prompt on Windows).
Head over to the /path/to/your/project/, which we would refer to as the Project Root.
While at the project root, remove the "Console" plugin from your set of plugins.The command is: cordova plugin rm cordova-plugin-console
While still at the project root, use the cordova build command to create an APK for release distribution.The command is: cordova build --release android
The above process creates a file called android-release-unsigned.apk in the folder ProjectRoot/platforms/android/build/outputs/apk/
Sign and align the APK using the instructions at https://developer.android.com/studio/publish/app-signing.html#signing-manuallyAt the end of this step the APK which you get can be uploaded to the Play Store.
Note: As a newbie or a beginner, the last step may be a bit confusing as it was to me. One may run into a few issues and may have some questions as to what these commands are and where to find them.
Q1. What are jarsigner and keytool?
Ans: The Android App Signing instructions do tell you specifically what jarsigner and keytool are all about BUT it doesn't tell you where to find them if you run into a 'command not found error' on the command line window.
Thus, if you've got the Java Development Kit(JDK) added to your PATH variable, simply running the commands as in the Guide would work. BUT, if you don't have it in your PATH, you can always access them from the bin folder of your JDK installation.
Q2. Where is zipalign?
Ans: There is a high probability to not find the zipalign command and receive the 'command not found error'. You'd probably be googling zipalign and where to find it?
The zipalign utility is present within the Android SDK installation folder. On macOS, the default location is at, user-name/Library/Android/sdk/. If you head over to the folder you would find a bunch of other folders like docs, platform-tools, build-tools, tools, add-ons...
Open the build-tools folder. cd build-tools. In here, there would be a number of folders which are versioned according to the build tool-chain you are using in the Android SDK Manager. ZipAlign is available in each of these folders. I personally go for the folder with the latest version on it. Open Any.
On macOS or Linux you may have to use ./zipalign rather than simply typing in zipalign as the documentation mentions. On Windows, zipalign is good enough.

Build android release apk on Phonegap 3.x CLI

How can I build an android app locally using the Phonegap 3.x CLI, ready to release? I check the bin folder generated inside the platforms/android directory of the project, and only has .debug APKs.
By the way, I use this command: phonegap local build android
This is for Phonegap 3.0.x to 3.3.x. For PhoneGap 3.4.0 and higher see below.
Found part of the answer here, at Phonegap documentation. The full process is the following:
Open a command line window, and go to /path/to/your/project/platforms/android/cordova.
Run build --release. This creates an unsigned release APK at /path/to/your/project/platforms/android/bin folder, called YourAppName-release-unsigned.apk.
Sign and align the APK using the instructions at android developer official docs.
Thanks to #LaurieClark for the link (http://iphonedevlog.wordpress.com/2013/08/16/using-phonegap-3-0-cli-on-mac-osx-10-to-build-ios-and-android-projects/), and the blogger who post it, because it put me on the track.
In PhoneGap 3.4.0 you can call:
cordova build android --release
If you have set up the 'ant.properties' file in 'platforms/android' directory like the following:
key.store=/Path/to/KeyStore/myapp-release-key.keystore
key.alias=myapp
Then you will be prompted for your keystore password and the output file (myapp-release.apk) ends up in the 'platforms/android/ant-build' directory already signed and aligned and ready to deploy.
In cordova 6.2.0
cd cordova/ #change to root cordova folder
platforms/android/cordova/clean #clean if you want
cordova build android --release -- --keystore="/path/to/keystore" --storePassword=password --alias=alias_name #password will be prompted if you have any
Previous answer:
According to cordova 5.0.0
{
"android": {
"release": {
"keystore": "app-release-key.keystore",
"alias": "alias_name"
}
}
}
and run ./build --release --buildConfig build.json from directory platforms/android/cordova/
keystore file location is relative to platforms/android/cordova/, so in above configuration .keystore file and build.json are in same directory.
keytool -genkey -v -keystore app-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Following up to #steven-anderson
you can also configure passwords inside the ant.properties, so the process can be fully automated
so if you put in platform\android\ant.properties the following
key.store=../../yourCertificate.jks
key.store.password=notSoSecretPassword
key.alias=userAlias
key.alias.password=notSoSecretPassword
just wondered around a lot because I got the same issue but in my installation the command "cordova" was never available and "phone gap build android --release" just ignored the platform/android/ant.properties.
so looking inside my platform filter I found a folder named "cordova" and inside of it there was an "build" binary that accepted the --release argument, it asked me for the key chains and I ended with a signed and ready for production APK.
this was never documented in any part of the phone gap site and frankly speaking now I kinda hate phonegap :( it was supposed to make the things easier but everything was just complicated :(
Building PhoneGap Android app for deployment to the Google Play Store
These steps would work for Cordova, PhoneGap or Ionic. The only difference would be, wherever a call to cordova is placed, replace it with phonegap or ionic, for your particular scenario.
Once you are done with the development and are ready to deploy, follow these steps:
Open a command line window (Terminal on macOS and Linux OR Command Prompt on Windows).
Head over to the /path/to/your/project/, which we would refer to as the Project Root.
While at the project root, remove the "Console" plugin from your set of plugins.The command is: cordova plugin rm cordova-plugin-console
While still at the project root, use the cordova build command to create an APK for release distribution.The command is: cordova build --release android
The above process creates a file called android-release-unsigned.apk in the folder ProjectRoot/platforms/android/build/outputs/apk/
Sign and align the APK using the instructions at https://developer.android.com/studio/publish/app-signing.html#signing-manuallyAt the end of this step the APK which you get can be uploaded to the Play Store.
Note: As a newbie or a beginner, the last step may be a bit confusing as it was to me. One may run into a few issues and may have some questions as to what these commands are and where to find them.
Q1. What are jarsigner and keytool?
Ans: The Android App Signing instructions do tell you specifically what jarsigner and keytool are all about BUT it doesn't tell you where to find them if you run into a 'command not found error' on the command line window.
Thus, if you've got the Java Development Kit(JDK) added to your PATH variable, simply running the commands as in the Guide would work. BUT, if you don't have it in your PATH, you can always access them from the bin folder of your JDK installation.
Q2. Where is zipalign?
Ans: There is a high probability to not find the zipalign command and receive the 'command not found error'. You'd probably be googling zipalign and where to find it?
The zipalign utility is present within the Android SDK installation folder. On macOS, the default location is at, user-name/Library/Android/sdk/. If you head over to the folder you would find a bunch of other folders like docs, platform-tools, build-tools, tools, add-ons...
Open the build-tools folder. cd build-tools. In here, there would be a number of folders which are versioned according to the build tool-chain you are using in the Android SDK Manager. ZipAlign is available in each of these folders. I personally go for the folder with the latest version on it. Open Any.
On macOS or Linux you may have to use ./zipalign rather than simply typing in zipalign as the documentation mentions. On Windows, zipalign is good enough.
i got this to work by copy pasting the signed app in the same dir as zipalign. It seems that aapt.exe could not find the source file even when given the path. i.e.
this did not work
zipalign -f -v 4 C:...\CordovaApp-release-unsigned.apk C:...\destination.apk
it reached aapt.exeCordovaApp-release-unsigned.apk , froze and upon hitting return
'aapt.exeCordovaApp-release-unsigned.apk' is not recognized as an internal or external command, operable program or batch file.
And this did
zipalign -f -v 4 CordovaApp-release-unsigned.apk myappname.apk
I know this question asks about Phonegap 3.X specifically, but just for reference any Phonegap version above 4.0.0 uses Gradle instead of Ant to build by default. To use Ant instead of Gradle you can add this to your config.xml:
<preference name="android-build-tool" value="ant" />
When using Gradle the keystore signing information now needs to go into a new location (as outlined in this post). Create new file called 'release-signing.properties' in the same folder as "build.gradle" file and put inside the following content:
storeFile=..\\..\\some-keystore.keystore
storeType=jks
keyAlias=some-key
// if you don't want to enter the password at every build, you can store it with this
keyPassword=your-key-password
storePassword=your-store-password
You could try this command, it should build and run the app (so .apk should be created) :
phonegap local run android

Cordova's distro files (jar) are not generated

I'm trying to start a simple Cordova 3.0.0 project under Windows. Development environment (including Java, Eclipse, Ant, Android SDK) does exist and has been already used for numerous native apps.
I was able to create a "hello" project using:
>create hellocordova com.example.hellocordova "HelloWorldCordova"
Creating new android project...
Building jar and js files...
Copying template files...
Copying js, jar & config.xml files...
Creating appinfo.jar...
Copying cordova command tools...
Updating AndroidManifest.xml and Main Activity...
It worked ok, though there are no distro files in the project.
After that I've tried to build Cordova's distro files using update:
>update hellocordova
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Building jar and js files...
Copying js, jar & config.xml files...
Copying cordova command tools...
It does not show any errors, but the files cordova-3.0.0.jar and cordova-3.0.0.js are missing in respective folders (libs and assets/www) where they should appear.
The problem could possibly be related to API Level (though I'm not sure how). check_reqs reports:
Please install Android target 17 (the Android 4.2 SDK).
Yes, I have 4.1 as the highest API level at the moment and would like to keep it so. But I don't see in Cordova scripts any indication that the level must be exactly 17, except for the check_reqs itself, which seems not involved in building process.
I'd appreciate suggestions how to fix this.
It looks like I missed the step which does actually build the jar-file:
ant jar
for Cordova framework project. I didn't see this in the documentation.
After further investigation I found that create and update executes this command inside:
exec('ant.bat -f \"'+ ROOT +'\\framework\\build.xml\" jar');
The problem is that the command executes well manually, that is it produces the jar, but it silently fails to produce it when invoked inside create or update. For clarity I outputted the resulting command line from update, then copy & paste it and run in shell in the same directory. This works properly.
I had the same problem as you for the last couple of hours and problem came (silently as you said :D) from ant. My version of ant was not recent enough (1.7 instead of 1.8).
After updating it seems to work great (jar generated in correct file) even automatically (read inside the phonegap command scripts like run android).
I had the same issue but i was missing
ANDROID_HOME=C:\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17\bin
And the Path to Java.
the -d ( i think debug ) will give you more information.
create -d hellocordova com.example.hellocordova "HelloWorldCordova"
this was on Cordova 3.0.9 and adt-bundle-windows-x86_64-20130729.
Als do not forget to update the SDK so the you have the corect Android platforms.

Categories

Resources