Ionic 2 Build succeeds but no APK generated - build

I am using Ionic 2. I can use ionic serve fine. When I try to use the build command, or the run command for either Android or iOS, the command succeeds, but no apk nor ipa is generated. There are no build folders under the platorm folders.
E.g.
ionic build android
outputs the following:
> ionic-app-scripts build
[00:35:55] ionic-app-scripts 0.0.45
[00:35:55] build prod started ...
[00:35:55] clean started ...
[00:35:55] clean finished in 5 ms
[00:35:55] copy started ...
[00:35:55] ngc started ...
[00:35:55] copy finished in 93 ms
[00:36:07] ngc finished in 12.19 s
[00:36:07] webpack started ...
[00:36:14] webpack finished in 7.00 s
[00:36:14] uglifyjs started ...
[00:36:14] sass started ...
[00:36:15] sass finished in 922 ms
[00:36:15] cleancss started ...
[00:36:16] cleancss finished in 924 ms
[00:36:22] uglifyjs finished in 8.68 s
[00:36:22] build prod finished in 27.88 s

Try this. I assume you already have the android sdk installed.
ionic platform add android
ionic build android
It will generate the apk, but it will take a good time.

Related

ionic cordova run android adb command failed with exit code 137

i am new to ionic and i start basic tabs project using ionic cli. Everything is working fine, except when i tried "ionic cordova run android" command with redmi note 4 giving following error.
Error: Failed to execute shell command "input,keyevent,82"" on device: Error: adb: Command failed with exit code 137
it is working fine on redmi note 3, follow is log from terminal, Any help would be appreciated
[INFO] Running app-scripts build: --platform android --target cordova
[23:22:39] build dev started ...
[23:22:39] clean started ...
[23:22:39] clean finished in 6 ms
[23:22:39] copy started ...
[23:22:39] deeplinks started ...
[23:22:39] deeplinks finished in 64 ms
[23:22:39] transpile started ...
[23:22:45] transpile finished in 5.99 s
[23:22:45] preprocess started ...
[23:22:45] copy finished in 6.38 s
[23:22:46] preprocess finished in 229 ms
[23:22:46] webpack started ...
[23:23:08] webpack finished in 22.92 s
[23:23:08] sass started ...
[23:23:12] sass finished in 3.52 s
[23:23:12] postprocess started ...
[23:23:12] postprocess finished in 11 ms
[23:23:12] lint started ...
[23:23:12] build dev finished in 32.98 s
> cordova run android --device
ANDROID_HOME=/home/rogers/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
[23:23:18] lint finished in 5.77 s
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_rbfqc9qtl315khhol1quvz1g.run(/home/rogers/workspace/practice/myApp/platforms/android/build.gradle:141)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild
UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders
UP-TO-DATE
:CordovaLib:generateDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
UP-TO-DATE
:CordovaLib:packageDebugRenderscript
UP-TO-DATE
:CordovaLib:compileDebugRenderscript
UP-TO-DATE
:CordovaLib:generateDebugResValues
UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources
UP-TO-DATE
:CordovaLib:processDebugManifest
UP-TO-DATE
:CordovaLib:generateDebugBuildConfig
UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders
UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug
UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib630DebugLibrary
UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl
UP-TO-DATE
:compileDebugRenderscript
UP-TO-DATE
:generateDebugBuildConfig
UP-TO-DATE
:generateDebugResValues
UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources
UP-TO-DATE
:processDebugManifest
UP-TO-DATE
:processDebugResources
UP-TO-DATE
:generateDebugSources
UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac
UP-TO-DATE
:compileDebugNdk
UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets
UP-TO-DATE
:mergeDebugAssets
UP-TO-DATE
:transformClassesWithDexForDebug
UP-TO-DATE
:mergeDebugJniLibFolders
UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes
UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
UP-TO-DATE
:validateSigningDebug
:packageDebug
UP-TO-DATE
:assembleDebug
UP-TO-DATE
:cdvBuildDebug UP-TO-DATE
BUILD SUCCESSFUL
Total time: 3.045 secs
Built the following apk(s):
/home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/home/rogers/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Skipping build...
Built the following apk(s):
/home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
Using apk: /home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
Package name: io.ionic.starter
Error: Failed to execute shell command "input,keyevent,82"" on device: Error: adb: Command failed with exit code 137
[ERROR] An error occurred while running cordova run android --device (exit code 1).
this is a Xiaomi "Security" issue. You have to activate the "USB Debugging (Security settings)" in the developer options.
I hope this works for you as it worked for me :D
Turn On these both as shown in the Screenshot.
For MI phones dont't forget to enable USB debugging (Security settings)
For MI phones dont't forget to enable
USB debugging (Security settings)
First remove the android platform and add it again.
Use these 2 commands.one by one
1.ionic platform remove android.
2.ionic platform add android.
It works for me.
Since we're constantly reinstalling the app by copying it from the Ionic CLI to the device, there are couple of issues that I found that resulted the above's issue:
The app's version is lower than the one you try to install
uninstall the app - and try again
Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user] means that the USB debugging is either off or on, but the "installed via USB" is off ...
if you don't have enough space on the phone make sure to make a space on your storage
check the storage of the device if have enough storage is good.
else free some space.
after that re-run the command if isn't become successful, please check another device, the problem is that device

`ionic serve` doesn't reload/rebuild when changing files under app's sub folders

I'm trying to follow angular's folder-by-feature structure in my ionic3 project. So I create a feature folder under app folder, like this:
- src/
- app/
- about/
- about.module.ts
- components/
- about.component.html
- about.component.ts
- about.component.scss
When changing any file under about folder, ionic serve fire a rebuild process, but built files change nothing:
> ionic-app-scripts serve
[10:50:52] ionic-app-scripts 2.1.3
[10:50:52] watch started ...
[10:50:52] build dev started ...
[10:50:52] clean started ...
[10:50:52] clean finished in 3 ms
[10:50:52] copy started ...
[10:50:52] transpile started ...
[10:50:57] transpile finished in 4.74 s
[10:50:57] preprocess started ...
[10:50:57] deeplinks started ...
[10:50:57] deeplinks finished in 181 ms
[10:50:57] preprocess finished in 183 ms
[10:50:57] webpack started ...
[10:50:57] copy finished in 5.14 s
[10:51:08] webpack finished in 10.82 s
[10:51:08] sass started ...
[10:51:10] sass finished in 2.06 s
[10:51:10] postprocess started ...
[10:51:10] postprocess finished in 5 ms
[10:51:10] lint started ...
[10:51:10] build dev finished in 17.86 s
[10:51:10] watch ready in 17.95 s
[10:51:10] dev server running: http://localhost:8100/
// -----> change any files under about folder
[10:51:16] lint finished in 5.90 s
[10:52:51] build started ...
[10:52:51] template update started ...
[10:52:51] template update finished in 5 ms
[10:52:51] deeplinks update started ...
[10:52:53] deeplinks update finished in 1.59 s
[10:52:53] build finished in 1.60 s
Currently, I have to re-run ionic serve on every change.
How to make this work?

How can I avoid minify Javascript(main.js) on ionic 2 run?

I am using this command to run Ionic 2 project on android
ionic run -l -c -s --debug android
after I see such a exception
0 214474 error EXCEPTION: No component factory found for t
1 214477 error ORIGINAL STACKTRACE:
2 214484 error Error: No component factory found for t at e.Error (native)
at e [as constructor] (http://192.158.0.8:8100/build/main.js:5:5464)
The problem is that ionic run compiles everything to minified main.js file and it is nearly impossible to understand exceptions or debug on it.
Is there any way to skip minify step?
Or maybe there is a other solution to debug ionic 2 application?

Gradle test task - Gradle 1.6 and with Gradle 2.3 or later

I have a Java project.
PS: In my project, I don't have any java program/source code in src/test/java. - This folder just contains a blank.txt file.
I have two different Gradle versions:
Gradle 1.6 with Java 7 (as Java 8 is NOT compatible with Gradle 1.6 or any version < less than 1.10 version if I'm correct).
The other version is: Gradle 2.3 with Java 8.
Using both of the above mentioned Gradle 1.6 + Java7 OR Gradle 2.3 + Java 8 versions my project build successfully.
Though, I noticed one thing: That while running the build, it calls "test" task automatically (as per the Gradle design, test task runs for free); I found during Gradle 1.6 + Java7 run --- I see the following output.
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources
:testClasses
:test
:check
As you'll notice, it says I don't have any test source code (i.e. src/test/java doesn't contain any source code OR there's nothing new for Gradle to compile this time may be nothing changed since last time gradle ran the build) and that's why compileTestJava task is showing UP-TO-DATE in front of it.
But, :test task is showing that it ran successfully. I have used jacoco (code coverage) section within test { .. } task, then it actually ran that part (as there is no UP-TO-DATE in front of test task). Jacoco section is NOT defined in my project's build.gradle but actually it's coming from a top level / GRADLE_HOME/init.d/some-common-top-level.gradle file (where test { ... has jacoco { ... } .. } section in it).
As I mentioned above, test task didn't say UP-TO-DATE, therefore, after Gradle build process was complete, I can see it created the following folder/files structure inside build/tmp/expandedArchives/org.jacoco.... folder:
$ ls -ltr build/tmp/expandedArchives/
total 4
drwxr-xr-x+ 1 e020001 Domain Users 0 Jul 7 20:45 org.jacoco.agent-0.7.2.201409121644.jar_778m6tp3jrtvcetasufl59dmau
$ ls -ltr build/tmp/expandedArchives/org.jacoco.agent-0.7.2.201409121644.jar_778m6tp3jrtvcetasufl59dmau/
total 272
drwxr-xr-x+ 1 e020001 Domain Users 0 Jul 7 20:58 META-INF
-rwxr-xr-x 1 e020001 Domain Users 2652 Jul 7 20:58 about.html
-rwxr-xr-x 1 e020001 Domain Users 272311 Jul 7 20:58 jacocoagent.jar
drwxr-xr-x+ 1 e020001 Domain Users 0 Jul 7 20:58 org
The same is NOT happening when I'm running Gradle 2.3 and Java8.
Build is successful but I'm not getting build/tmp/expandedArchives/org.jacoco.... folder containing jacocoagent.jar file.
Any idea, why Gradle 2.3 is not creating this jacoco specific .jar file.
With Gradle 2.3+Java8, the following output shows UP-TO-DATE in front of both :compileTestJava and :test tasks (which was not the case with Gradle 1.6 for test task).
I ran "gradle clean build".
:compileTestJava UP-TO-DATE
:compileTestGroovy UP-TO-DATE
:processTestResources
:testClasses
:test UP-TO-DATE
:check
I need Gradle 2.3 to generate this jacocoagent.jar under build/tmp/expandedArchives/org.jacoco..... folder so that I can use it in a downstream Jenkins job (which runs non-Unit tests) as this project does have some Integration tests and I'm fetching the jacocoagent.jar from the parent main build job (which runs gradle clean build including test task) in downstream job so that I can pass it to TOMCAT JVM while starting Tomcat (so that I can get jacocoIT.exec code coverage for IT tests). But, after I switched to Gradle 2.3, all projects where I don't have src/test/java ... now jacocoagent.jar is not getting created and the copy artifact plugin fails while trying to copy the .jar file from parent job.
One more point:
With Gradle 1.6 + Java7, if I run gradle clean build, it successfully creates that jacocoagent.jar inside build/tmp/expandedArchives/org.jacoco..... folder but it works this way, only when I run gradle clean build or "gradle clean; gradle test".
If I run gradle clean build, and then remove build/tmp folder, and now just run: gradle test, it shows me UP-TO-DATE in front of both :compileTestJava and :test tasks and doesn't create build/tmp/expandedArchives/org.jacoco.... folder containing jacocoagent.jar file.
For more info, I'm attaching the profile run (i.e. using --profile option) while running gradle test task for Gradle 1.6 + java 7.
I see that, in the profile html file that when test task is run, it first calls compileJava as per Gradle process logic and then test task and it's also calling depedencies --- :jacocoAgent (as per the dependency resolution tab):
But,
with Gradle 2.3 + Java8, the dependency Resolution / order and Task execution step is not same (or in the order as compared to Gradle 1.6) for generating or showing any reference to jacocoAgent dependency as it's not even calling it.
Running Gradle1.6 +Java7 test task with -i (or --info) option shows why it ran test task even though I had no test source code, see the reason why:
Note: Recompile with -Xlint:unchecked for details.
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:classes
Skipping task ':classes' as it has no actions.
:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:compileTestJava UP-TO-DATE
:processTestResources
Executing task ':processTestResources' due to:
No history is available.
:testClasses
Skipping task ':testClasses' as it has no actions.
:test
file or directory '/my/workspace/project/build/classes/test', not found
Executing task ':test' due to:
No history is available.
file or directory '/my/workspace/project/build/classes/test', not found
Finished generating test XML results (0.001 secs)
Generating HTML test report...
Finished generating test html results (0.012 secs)
BUILD SUCCESSFUL
you can force the test task to be executed no matter what the status of inputs and outputs are:
test{
outputs.upToDateWhen{false}
}
for earlier gradle versions you can ensure the class directory exists by
task createTestClassesDir << {sourceSets.test.output.classesDir.mkdirs()}
test.dependsOn createTestClassesDir
Summary:
With Gradle 2.3, if there are no valid .java/.groovy (or etc) test code, then test task won't even run and thus there'll be no jacocoagent.jar created somewhere deep in build/tmp/exapandedArchives/org.jacoco.xxx.... folder.
Solution was to include the following (in top level $GRADLE_HOME/init.d/some-global-file.gradle) inside allprojects { .... } section. All we are doing is, if src/test/java (standard) or any legacy folder structure (src/java if your project structure is like this) doesn't have any valid test source code, then we can add a dummy test file (DummyTestXYZ.java or groovy) and let test task run which will generate jacocoagent.jar (which we can use / tie in Tomcat options for generating jacoco report for non-unit aka integration tests). This way, if your main build job calls a downstream/child job to run your IT tests, it won't fail as it can fetch jacocoagent.jar (from main build job's workspace) as test task will create jacocoagent.jar in build/tmp/expandedArchives/org.jacoco.xx.x.xx..x folder (that you can get using Copy Artifact plugin in Jenkins).
PS: Change the if statement logic acc. to your own folder setup i.e. in which folder you'd want to create the DummyTestXYZ.java file. In our case, all new projects were using src/test/java (standard folder structure as per Maven/Gradle standard) and during the new project creation, we are adding valid sample unit tests checked-in to the source control. Thus, in the logic below, we are actually ignoring to create this DummyTestXYZ.java in case src/test/java exists and creating this file only if src/test/java folder doesn't exist in the project (i.e. this is a project which has legacy folder structure) + test/java (legacy folder for storing JUnit unit tests) has no .java programs and/or if test/java doesn't exist then create it first and then create the dummy file. I know, we could have uploaded jacocoagent.jar at some location on Jenkins server and use that file while starting Tomcat for getting code coverage for IT tests. The dummy test file we added requires junit:junit:4.10 or 4.11 library version for the :compileTestJava task to succeed.
compileJava {
doLast {
def dirName = "${projectDir}/test/java"
if(!file( "${projectDir}/src/test/java" ).exists())
if(!file( dirName ).exists())
new File( dirName ).mkdirs()
if(file( dirName ).exists()) {
def javaCnt = new FileNameByRegexFinder().getFileNames(dirName, /.*\.java/).size()
if(javaCnt == 0) {
def f = new File( dirName , 'DummyTestXYZ.java' )
def w = f.newPrintWriter()
w.println('import org.junit.Test;')
w.println('')
w.println('public class DummyTestXYZ {')
w.println('#Test' )
w.println('public void test() {')
w.println('}')
w.println('}')
w.close()
}
}
}
}
test {
doFirst {
testResultsDirName = "test-results/UT"
testReportDirName = "tests/UT"
}
maxParallelForks = 5
forkEvery = 50
//ignoreFailures = true
// Following Jacoco section is required only in Jenkins
// But a developer can uncomment them if they want this feature to work for their
// Desktop local Gradle builds.
jacoco {
//Following vars works only with versions >= 1.7 version of Gradle
destinationFile = file("$buildDir/jacoco/UT/jacocoUT.exec")
}
doLast {
if (file("${projectDir}/test/java/DummyTestXYZ.java").exists()) {
println "++"
println "++"
println "++"
println "======================================================="
println "DEV Team – Please add valid Unit tests in this project."
println "======================================================="
println "++"
println "++"
println "++"
sleep(30 * 1000)
new File("${projectDir}/build/classes/test").deleteDir()
new File("${buildDir}/jacoco/UT").deleteDir()
new File("${buildDir}/test-results/UT").deleteDir()
delete "${projectDir}/test/java/DummyTestXYZ.java"
}
}
}
//Do the same (as above test code) for any other similar test tasks like integartionTest, acceptanceTest etc..
jacocoTestReport {
//cleaning any compile time generated (for ex: JiBx classes files) so that jacoco task won't fail for not finding the actual source files (.java/.groovy for the compile time generated .class files)
doFirst {
delete fileTree (dir: "${buildDir}/classes", include: "**/JiBX_*.class")
}
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
//ignoreFailures = true
executionData = fileTree(dir: 'build/jacoco', include: '**/*.exec')
reports {
xml{
enabled true
//Following value is a file
destination "${buildDir}/reports/jacoco/xml/jacoco.xml"
}
csv.enabled false
html{
enabled true
//Following value is a folder
destination "${buildDir}/reports/jacoco/html"
}
}
sourceDirectories = files(['src/java','src/main/java', 'src/main/groovy'])
classDirectories = files('build/classes/main')
doLast {
if (file("${projectDir}/test/java/DummyTestXYZ.java").exists()) {
delete "${projectDir}/test/java/DummyTestXYZ.java"
}
}
}

building chromium latest release on android

I have to build latest release of chromium browser for android.
I am using the following step,
Create a Chromium root directory
mkdir chromium ; cd chromium
Download and export PATH of depot_tools
export PATH=$PATH:~/path/to/depot_tools/
Checked out the source for build 32.0.1665.2
gclient config https://src.chromium.org/chrome/releases/32.0.1665.2
4 The above command create a .gclient file in chromium root directory, and add the target android in .gclient.
target_os = ['android']
To download the initial code:
gclient sync
Install the Dependencies
6.1) cd /path/to/chromium/src
6.2) ./build/install-build-deps.sh
gclient runhooks call GYP to generate your platform-specific files. This should give you a complete source tree
gclient runhooks
Compile :
To build the ARM Android content shell:
1) cd /path/to/chromium/src
2) . build/android/envsetup.sh
3) android_gyp
4) ninja -C out/Release -j10 content_shell_apk
After following the above command i am getting the content_shell.apk which has version chrome/19.77.34.5, i am checking the version of chromium using the link http://whatsmyuseragent.com,
Please help me to build chromium latest version(32.0.1665.2) on android
Content shell does not display correct user agent version in android as well as linux (right now content_shell displays chrome/19.77.34.5).
This seems to be deliberate from src/content/content_shell.gypi
'variables': {
'content_shell_product_name': 'Content Shell',
# The "19" is so that sites that sniff for version think that this is
# something reasonably current; the "77.34.5" is a hint that this isn't a
# standard Chrome.
'content_shell_version': '**19.77.34.5**',
You can always use chromium_testshell which will give correct version (which is currently Chrome/35.0.1879.0).