tips:ionic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tips:ionic [2017/07/28 08:15] – [Android] scipiotips:ionic [2017/08/07 13:54] (current) scipio
Line 2: Line 2:
  
 ===== Prerequisites ===== ===== Prerequisites =====
- 
  
 ==== nodejs (latest) ==== ==== nodejs (latest) ====
Line 19: Line 18:
 </code> </code>
  
-===== Project ===== +===== Create library =====
-==== Create library ====+
  
 <code bash> <code bash>
Line 37: Line 35:
 npm update -g ionic cordova npm update -g ionic cordova
 </code> </code>
-==== Create project ==== 
  
-  * https://devdactic.com/login-ionic-2/ +===== Update libs =====
-  * https://ionicacademy.com/ionic-3-lazy-loading/ +
-  * https://www.joshmorony.com/an-introduction-to-observables-for-ionic-2/ +
- +
-Activate library +
-<code bash> +
-. $LIB/bin/activate +
-</code> +
- +
-<code bash> +
-NAME=PeperStart +
-ionic start $NAME blank +
-cd $NAME +
-ionic browser add crosswalk #(this command enable also android platform) +
-</code> +
- +
-==== Update libs ====+
  
 <code bash> <code bash>
Line 65: Line 46:
 </code> </code>
  
-==== 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:
 </code> </code>
  
-example3 with custom plugin +==== Add java sources and native C++ support ====
-<code> +
-ionic start GianoDroidHybrid blank --id org.csgalileo.gianodroidhybrid +
-cd GianoDroidHybrid +
-rm -fR .git +
-ionic cordova platform add android +
-ionic cordova plugin add ../cordova-plugin-giano+
  
-</code>+Add opencv support http://wiki.csgalileo.org/projects:giano:android#simpler_mode
  
-==== Android Studio ====+In <project root> add: 
 +CMakeLists.txt 
 +<file> 
 +cmake_minimum_required(VERSION 3.4.1) 
 +set(CMAKE_VERBOSE_MAKEFILE on) 
 +find_library(log-lib log)
  
-After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder <project-root>/platforms/android (choose to update gradle).+set(OpenCV_DIR "android-opencv/opencv/src/sdk/native/jni"
 +find_package(OpenCV REQUIRED) 
 +message(STATUS "OpenCV libraries: ${OpenCV_LIBS}"
 +</file>
  
-Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in <project-root>/src and synced with 'ionic build+and add to //build-extras.gradle// (this file is copied with hook <hook src="scripts/gradle.sh" type="after_platform_add" />) 
-==== Eclipse ====+<file> 
 +android { 
 +  externalNativeBuild { 
 +    cmake { 
 +      path "../../CMakeLists.txt" 
 +    } 
 +  } 
 +  packagingOptions { 
 +    // edit also abiFilters and clean project before make apk 
 +    //exclude 'lib/armeabi-v7a/libopencv_java3.so
 +    exclude 'lib/mips/libopencv_java3.so' 
 +    exclude 'lib/mips64/libopencv_java3.so' 
 +    exclude 'lib/armeabi/libopencv_java3.so' 
 +    exclude 'lib/x86/libopencv_java3.so' 
 +    exclude 'lib/x86_64/libopencv_java3.so' 
 +  }
  
-$P is $NAME/platforms/android path+}
  
-  * Import -> "Existing Android Code ..." -> $NAME/platforms/android and deselect all subprojects +dependencies { 
-  * Project -> Build Path -> Configure Build Path +  compile project(':android-opencv:opencv') 
-    * Source -> Link source -> $P/Cordovalib/src with name src-cordovalib +}
-    * Libraries -> Add external JAR -> $P/Cordovalib/xwalk_core_library/xwalk_core_library_java_app_part.jar +
-    * Libraries -> Add external JAR -> $P/Cordovalib/xwalk_core_library/xwalk_core_library_java_library_part.jar+
  
-==== Native lib integration ====+ext.postBuildExtras 
 +  logger.quiet('adding java sources'
 +  android { 
 +    sourceSets { 
 +      main.java.srcDirs +'../../src/android/java' 
 +      main.res.srcDirs +'../../src/android/res' 
 +    } 
 +  } 
 +
 +</file>
  
-Create zip file named **gpio.jar** and put into platforms/android/libs +from build.gradle of android-opencv comment classpath from dependancies 
-<code+<file
-lib +dependencies { 
-└── armeabi +        //classpath 'com.android.tools.build:gradle:2.3.3'
-    └── libgpio.so +
-</code>+
  
-build.gradle search inside libs for *jar (see dependancy section) +        // NOTE: Do not place your application dependencies here; they belong 
-===== Tips =====+        // in the individual module build.gradle files 
 +    } 
 +</file>
  
-==== Video fullscreen autoplay ====+with <hook src="scripts/gradle.sh" type="after_platform_add" /> apply patch to change settings.gradle in 
 +<file> 
 +include ":" 
 +include ":CordovaLib" 
 +include ":android-opencv:opencv" 
 +project(":android-opencv:opencv").projectDir new File("../../android-opencv/opencv"
 +</file> 
 + 
 +with <hook src="scripts/config.xml.py" type="before_compile" /> patch **res/xml/config.xml** to export plugin interface, for example 
 +<file xml res/xml/config.xml> 
 + <feature name="TestPlugin"> 
 + <param name="android-package" value="org.csgalileo.giano.TestPlugin"></param> 
 + <param name="onload" value="true"></param> 
 + </feature> 
 +</file> 
 + 
 +define typescript interface 
 +<file typescript src/app/test.module.ts> 
 +import { Injectable } from '@angular/core'; 
 + 
 +declare var cordova:any; 
 + 
 +@Injectable() 
 +export class TestPlugin { 
 +    public testCall() { 
 +        cordova.exec( 
 +                function(data) { console.log("test-plugin getDate="+data); }, 
 +                function(error) { console.log("test-plugin:"+error); }, 
 +                "TestPlugin", 
 +                "getDate", 
 +                []); 
 +    } 
 +
 +</file> 
 + 
 +===== Android Studio ===== 
 + 
 +After project creation via cli (see up) import project (Eclipse, ADT, gradle) from folder <project-root>/platforms/android (choose to update gradle). 
 + 
 +Now it is possible to develop JAVA code in Android Studio but HTML/TS has to be changed in <project-root>/src and synced with 'ionic build'
  
-<code html> 
-<video ng-controller="startVideo" controls="" style="width:100%; height:auto" autoplay="false"> 
-   <source src=""></source> 
-</video> 
-</code> 
  
-<code javascript> 
-.controller('startVideo', function($scope) { 
-  angular.element('video').attr('src','http://...'); 
-}); 
-</code> 
  • tips/ionic.1501222544.txt.gz
  • Last modified: 2017/07/28 08:15
  • by scipio