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 15:44] – [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 add to // |
< | < | ||
android { | android { | ||
+ | externalNativeBuild { | ||
+ | cmake { | ||
+ | path " | ||
+ | } | ||
+ | } | ||
+ | packagingOptions { | ||
+ | // edit also abiFilters and clean project before make apk | ||
+ | //exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | exclude ' | ||
+ | } | ||
- | // ... | + | } |
- | | + | dependencies |
- | | + | |
- | path " | + | } |
- | } | + | |
- | | + | ext.postBuildExtras = { |
- | packagingOptions | + | |
- | // edit also abiFilters and clean project before make apk | + | |
- | | + | |
- | | + | |
- | exclude ' | + | main.res.srcDirs += '../../src/android/res' |
- | exclude 'lib/armeabi/ | + | |
- | exclude 'lib/x86/libopencv_java3.so' | + | |
- | exclude 'lib/x86_64/ | + | |
} | } | ||
+ | } | ||
} | } | ||
</ | </ | ||
- | ==== Android Studio ==== | ||
- | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder | + | from build.gradle |
+ | <file> | ||
+ | dependencies { | ||
+ | | ||
- | Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in < | + | |
- | ==== Eclipse ==== | + | // in the individual module |
+ | } | ||
+ | </ | ||
- | $P is $NAME/platforms/ | + | with <hook src=" |
+ | < | ||
+ | include ":" | ||
+ | include ": | ||
+ | include ":android-opencv: | ||
+ | project(": | ||
+ | </ | ||
- | * Import -> "Existing Android Code ..." | + | with <hook src="scripts/ |
- | | + | <file xml res/xml/config.xml> |
- | | + | < |
- | * Libraries -> Add external JAR -> $P/Cordovalib/ | + | <param name=" |
- | * Libraries -> Add external JAR -> $P/Cordovalib/xwalk_core_library/ | + | <param name=" |
+ | </feature> | ||
+ | </file> | ||
- | ==== Native lib integration ==== | + | define typescript interface |
+ | <file typescript src/ | ||
+ | import { Injectable } from ' | ||
- | Create zip file named **gpio.jar** and put into platforms/ | + | declare var cordova: |
- | < | + | |
- | lib | + | |
- | └── armeabi | + | |
- | └── libgpio.so | + | |
- | </ | + | |
- | build.gradle search inside libs for *jar (see dependancy section) | + | @Injectable() |
- | ===== Tips ===== | + | export class TestPlugin { |
+ | public testCall() { | ||
+ | cordova.exec( | ||
+ | function(data) { console.log(" | ||
+ | function(error) { console.log(" | ||
+ | " | ||
+ | " | ||
+ | []); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | ==== Video fullscreen autoplay | + | ===== Android Studio |
+ | |||
+ | After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder < | ||
+ | |||
+ | 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(' | ||
- | }); | ||
- | </ |