Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| tips:ionic [2017/07/31 16:26] – [Android] scipio | tips:ionic [2017/08/07 13:54] (current) – scipio | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== Prerequisites ===== | ===== Prerequisites ===== | ||
| - | |||
| ==== nodejs (latest) ==== | ==== nodejs (latest) ==== | ||
| Line 19: | Line 18: | ||
| </ | </ | ||
| - | ===== Project ===== | + | ===== Create library |
| - | ==== Create library ==== | + | |
| <code bash> | <code bash> | ||
| Line 37: | Line 35: | ||
| npm update -g ionic cordova | npm update -g ionic cordova | ||
| </ | </ | ||
| - | ==== Create project ==== | ||
| - | * https:// | + | ===== Update libs ===== |
| - | * https:// | + | |
| - | * https:// | + | |
| - | + | ||
| - | Activate library | + | |
| - | <code bash> | + | |
| - | . $LIB/ | + | |
| - | </ | + | |
| - | + | ||
| - | <code bash> | + | |
| - | NAME=PeperStart | + | |
| - | ionic start $NAME blank | + | |
| - | cd $NAME | + | |
| - | ionic browser add crosswalk #(this command enable also android platform) | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Update libs ==== | + | |
| <code bash> | <code bash> | ||
| Line 65: | Line 46: | ||
| </ | </ | ||
| - | ==== Android ==== | + | ===== Android |
| It is important to install native gradle or use gradle shipped with android studio (see PATH below) | It is important to install native gradle or use gradle shipped with android studio (see PATH below) | ||
| Line 108: | Line 89: | ||
| </ | </ | ||
| - | example3 with custom plugin | + | ==== Add java sources and native |
| - | < | + | |
| - | ionic start GianoDroidHybrid blank --id org.csgalileo.gianodroidhybrid | + | |
| - | cd GianoDroidHybrid | + | |
| - | rm -fR .git | + | |
| - | ionic cordova platform add android | + | |
| - | ionic cordova plugin add ../ | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | === Add Native | + | |
| Add opencv support http:// | Add opencv support http:// | ||
| - | In android root project (<project root>/ | + | In <project root> add: |
| CMakeLists.txt | CMakeLists.txt | ||
| < | < | ||
| Line 134: | Line 105: | ||
| </ | </ | ||
| - | and add to existing buid.gradle (android section and dependencies section) | + | and add to // |
| < | < | ||
| android { | android { | ||
| + | externalNativeBuild { | ||
| + | cmake { | ||
| + | path " | ||
| + | } | ||
| + | } | ||
| + | packagingOptions { | ||
| + | // edit also abiFilters and clean project before make apk | ||
| + | //exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | exclude ' | ||
| + | } | ||
| - | // ... | ||
| - | |||
| - | | ||
| - | cmake { | ||
| - | path " | ||
| - | } | ||
| - | } | ||
| - | packagingOptions { | ||
| - | // edit also abiFilters and clean project before make apk | ||
| - | //exclude ' | ||
| - | exclude ' | ||
| - | exclude ' | ||
| - | exclude ' | ||
| - | exclude ' | ||
| - | exclude ' | ||
| - | } | ||
| } | } | ||
| dependencies { | dependencies { | ||
| - | // ... | + | |
| - | | + | } |
| + | |||
| + | ext.postBuildExtras = { | ||
| + | logger.quiet(' | ||
| + | android { | ||
| + | sourceSets { | ||
| + | main.java.srcDirs += ' | ||
| + | main.res.srcDirs += ' | ||
| + | } | ||
| + | } | ||
| } | } | ||
| </ | </ | ||
| Line 171: | Line 149: | ||
| } | } | ||
| </ | </ | ||
| - | ==== Android Studio ==== | ||
| - | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder | + | with <hook src=" |
| + | <file> | ||
| + | include ":" | ||
| + | include ": | ||
| + | include ": | ||
| + | project(": | ||
| + | </ | ||
| - | Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in <project-root> | + | with <hook src=" |
| - | ==== Eclipse ==== | + | <file xml res/xml/ |
| + | <feature name=" | ||
| + | <param name=" | ||
| + | <param name=" | ||
| + | </ | ||
| + | </ | ||
| - | $P is $NAME/platforms/android path | + | define typescript interface |
| + | <file typescript src/app/test.module.ts> | ||
| + | import { Injectable } from ' | ||
| - | * Import -> " | + | declare var cordova: |
| - | * Project -> Build Path -> Configure Build Path | + | |
| - | * Source -> Link source -> $P/ | + | |
| - | * Libraries -> Add external JAR -> $P/ | + | |
| - | * Libraries -> Add external JAR -> $P/ | + | |
| - | ==== Native lib integration ==== | + | @Injectable() |
| + | export class TestPlugin { | ||
| + | public testCall() { | ||
| + | cordova.exec( | ||
| + | function(data) { console.log(" | ||
| + | function(error) { console.log(" | ||
| + | " | ||
| + | " | ||
| + | []); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| - | Create zip file named **gpio.jar** and put into platforms/ | + | ===== Android Studio ===== |
| - | < | + | |
| - | lib | + | |
| - | └── armeabi | + | |
| - | └── libgpio.so | + | |
| - | </ | + | |
| - | build.gradle search inside libs for *jar (see dependancy section) | + | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder < |
| - | ===== Tips ===== | + | |
| - | ==== Video fullscreen autoplay ==== | + | Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in < |
| - | <code html> | ||
| - | <video ng-controller=" | ||
| - | < | ||
| - | </ | ||
| - | </ | ||
| - | <code javascript> | ||
| - | .controller(' | ||
| - | angular.element(' | ||
| - | }); | ||
| - | </ | ||