美文网首页
Vue project package Android App

Vue project package Android App

作者: 草帽lufei | 来源:发表于2019-12-27 17:56 被阅读0次

    Install Cordova

    sudo npm install -g cordova

    Create Cordova Project

    cordova create android-app com.dls [project-name]

    Move dist (npm run build) directory to Cordova Project www directory

    Add andriod platfom

    android-app project root run command

    cordova platforms add android --save

    Check environment

    android-app project root run command

    cordova requirements

    Install Android Studio

    url: http://www.android-studio.org

    1. Extract to /usr/local/

    2. Execute ./studio.sh in android-studio/bin/

    3. create android project and set Android target (sdk)

    Configure Android SDK environment

    vim ~/.profile

    add code

    export ANDROID_HOME=$HOME/Android/Sdk
    export PATH=${PATH}:${ANDROID_HOME}/tools
    export PATH=${PATH}:${ANDROID_HOME}/platform-tools
    

    Install Java jdk

    url: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    Extract to /usr/local/

    Configure Java jdk

    vim /etc/profile

    add code

    export JAVA_HOME=/usr/local/jdk1.8.0_231
    export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$JAVA_HOME/bin:$PATH
    

    source /etc/profile

    e.g

    $ java -version
    java version "1.8.0_231"
    Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
    

    Install Gradle

    url: https://gradle.org/next-steps/?version=6.0.1&format=bin

    mkdir /opt/gradle

    Extract to /opt/gradle

    vim /etc/profile

    add code

    export PATH=$PATH:/opt/gradle/gradle-6.0.1/bin
    

    source /etc/profile

    Check the environment again

    android-app project root run command

    cordova requirements


    Generate apk

    Generage key

    keytool -genkey -v -keystore ./w.keystore -alias w.keystore -keyalg RSA -validity 2000

    w@w:~/my/app/android-app$ keytool -genkey -v -keystore ./w.keystore -alias w.keystore -keyalg RSA -validity 2000
    Enter keystore password:  
    Re-enter new password: 
    What is your first and last name?
      [Unknown]:  
    What is the name of your organizational unit?
      [Unknown]:  
    
    

    create build.json

    w@w:~/my/app/android-app$ vim build.json
    
    e.g
    
    {
      "android": {
        "release": {
          "keystore": "w.keystore",
          "alias": "w.keystore",
          "storePassword": "xxx",
          "password": "xxx"
        }
      }
    }
    

    Generate apk

    cordova build --release

    w@w:~/my/app/android-app/platforms/android/app/build/outputs/apk/release$ ls
    app-release.apk  output.json
    
    

    Chrome Debug Andriod App

    cordova run android

    chrome://inspect/#devices

    打包ios

    cordova platforms add ios --save

    cordova 项目根目录 build.json 中添加 ios

    相关文章

      网友评论

          本文标题:Vue project package Android App

          本文链接:https://www.haomeiwen.com/subject/ocgdoctx.html