Giter Club home page Giter Club logo

deprecated-crosswalk-apk-generator's Introduction

PLEASE USE Crosswalk App Tools instead of this tool.

Introduction

Crosswalk is a web runtime for Android, Tizen, Linux and Windows. It enables a developer to write an HTML5 application and run it on any of Crosswalk's supported platforms.

crosswalk-apk-generator makes it easy to generate an Android apk from an existing HTML5 application, using familiar web developer tools, languages and workflow. The resulting apk, when run in tandem with the Crosswalk Android runtime library, looks and feels like a native app.

crosswalk-apk-generator has been tested on the following platforms:

  • Fedora Core 17 Linux (64bit x86) with node v0.10.17
  • Windows 7 Enterprise (64bit x86) with node v0.10.12

It currently supports Crosswalk-4 and Crosswalk-5.

Installation

You will need node and npm installed first.

Then you can install crosswalk-apk-generator with:

npm install crosswalk-apk-generator

Before you can use it, you'll also need to install the pre-requisites required to build an Android package.

See the Command-line tools section for usage instructions.

How Crosswalk works

To run an app on Android using Crosswalk, you need a Crosswalk apk package for the HTML5 application you want to run, installed on the Android device. This has to be generated for each app, and is installed using adb (part of the Android SDK).

Depending on the mode you use when building the package, the apk file may or may not be architecture-specific. See the Embedded vs. shared mode section for details.

How crosswalk-apk-generator helps

Although scripts for packaging HTML5 apps already exist in the Crosswalk Android project, the aim of this project is to improve the developer experience by:

  1. Replacing the existing Crosswalk Android scripts for apk generation (make_apk.py and customize.py, primarily, but also some of the Ant scripts).
  2. Providing a library to make integration of apk generation with external tools simpler.
  3. Designing the tools so it's possible to improve their performance and add new features in a systematic way.
  4. Documenting and providing feedback on what's happening when an apk is generated, so it's easier to fix things when they go wrong.

So far, the APIs and scripts provided by this project replicate most of the functionality of the existing Crosswalk Android scripts, with the following exceptions:

  • No support for the --app-versionCode option
  • No support for generating an apk from a Crosswalk manifest via a --manifest option
  • Icon png files are not crunched using aapt during the build, as they are by make_apk.py. However, the crosswalk.png images in the res/drawable-* directories have been optimised using imagemin to reduce their size. We leave it to the packager's discretion to optimise their png files if using custom icons.

However, they provide several benefits over the existing Crosswalk Android scripts:

  • More transparent: this library exposes all of the dependencies required to create a Crosswalk Android apk file, shows you what they are, and clearly tells you when they're missing or can't be found.
  • More modular: the design enables the code to be more easily reused by third parties, as it provides an API for apk generation which is independent of command-line scripts (albeit still dependent on external command-line tools).
  • Better documented: the code is thoroughly commented to enable other developers to see what's happening when an apk is generated; the scripts can also provide feedback about which commands are being run when.

Pre-requisites

Unfortunately, building a Crosswalk Android apk still requires a lot of dependencies:

  • Android SDK for your platform from http://developer.android.com/sdk/index.html.

    Once you've got the Android SDK, run the SDK manager (SDK Manager.exe on Windows, android on Linux). Then install the Android SDK Build-tools, version 19. Note that while you may use other versions of the SDK build tools, these are the ones known to work.

  • xwalk-android distribution from https://download.01.org/crosswalk/releases/. Choose the right architecture for your Android device (x86 or arm).

    You can use the xwalk_android_dl script to fetch and unpack a Crosswalk Android distribution: see below for details.

  • Java JDK. Once installed, make sure you set the JAVA_HOME environment variable. It will also make life easier if you put the javac and jarsigner binaries on your PATH.

  • Apache Ant. Again, after installation, ensure that the ant binary is on your PATH.

  • If you want to distribute apks via an Android app store, you will need your own keystore. You can set this up using the Java keytool application. If you're only debugging your application, you can use the built-in xwalk-android keystore, which crosswalk-apk-generator will use by default.

Note that xwalk_android_dl has no dependencies other than node (and some third party node libraries).

Command-line tools

xwalk_android_dl: fetch and unpack xwalk-android

The xwalk_android_dl script downloads and unpacks a Crosswalk Android distribution, including the xwalk_app_template.tar.gz tarball (required to build a Crosswalk apk).

You can invoke it without any arguments to fetch the latest x86 beta of Crosswalk Android to the current directory:

xwalk_android_dl

Though the beta channel is the default, you can download the latest version from a different channel with:

xwalk_android_dl --channel canary

Pass the --arch option to download the latest version for a particular architecture (if not set, the default is x86):

xwalk_android_dl --arch arm --channel canary

Alternatively, you can specify an architecture and/or channel and/or version, and the script will figure out the package to download. Note that in this example, a different output directory (build) is specified:

xwalk_android_dl --version 2.31.23.0 \
  --arch arm --channel canary --outDir build

Finally, you can specify a package to download by absolute URL:

xwalk_android_dl --url https://download.01.org/crosswalk/releases/android/canary/crosswalk-3.31.34.0.zip

Once the package has been downloaded and unpacked, the location of crosswalkAndroidDir is shown. You can use this path when invoking the xwalk_apkgen tool (see below) to tell it where to find the xwalk_app_template directory.

If you're not sure which versions are available, you can invoke the script with --query to see a list. For example, to see the versions in the stable channel for x86:

xwalk_android_dl --query --channel stable --arch x86

Using the --query option with --json will output the query results in JSON format instead of the default human-readable format.

The script also supports proxies (though it's only been tested with plain http proxies, and not with https ones). To use a proxy, pass the --proxy option, for example:

xwalk_android_dl --query --proxy https://myproxy.com:8080

Note that if you have set the standard http_proxy environment variable, the script will use it by default.

To see the full range of options, invoke the script with the --help option.

xwalk_apkgen: create an apk

The xwalk_apkgen script (in the bin directory) builds a Crosswalk apk file from an existing HTML5 project. To run it, you will need all of the pre-requisites outlined above.

Apk generation can be configured in a variety of ways (with command-line options, and/or environment variables, and/or JSON files). To see all the available options, invoke xwalk_apkgen with the --help flag.

In most simple cases, you only need to specify a few options, like this:

xwalk_apkgen --androidSDKDir <android SDK directory> \
  --xwalkAndroidDir <xwalk-android template directory> \
  --appRoot <path to HTML5 application directory> \
  --appLocalPath <main HTML file relative to app-root> \
  --name <app name> \
  --package <app Java package> \
  --version <app version> \
  --outDir <output directory>

For example, given this Linux environment:

  • Android SDK directory = "/home/me/android-sdk-linux"
  • xwalk-android template directory = "/home/me/xwalk-android/xwalk_app_template" (Note that this is the directory location displayed by xwalk_android_dl; see above for details.)
  • path to HTML5 application = "/home/me/projects/myapp"
  • main HTML file = "index.html"
  • application name = "My app"
  • Java package = "me.myname.myapp"
  • application version = "0.0.1"
  • output directory = "build"

the command would be:

xwalk_apkgen --androidSDKDir /home/me/android-sdk-linux \
  --xwalkAndroidDir /home/me/xwalk-android/xwalk_app_template \
  --appRoot /home/me/projects/myapp \
  --appLocalPath index.html \
  --name "My app" \
  --package "me.myname.myapp" \
  --version 0.0.1 \
  --outDir build

This produces an apk file in the output directory you specified. The name of the output file is based on the --name you specified, with any path-sensitive characters replaced (whitespace, forward slashes etc.). In the example given, the final output apk would be in build/My_app.apk. All the intermediate files produced during the build will also be in the build directory.

Note that the output directory is not automatically cleaned before the build runs (to prevent accidental deletion of files). The recommended approach is to remove the content of the build directory before each run, to ensure the results are "clean". If outDir does have files in it, the xwalk_apkgen script will overwrite any which relate to the apk build.

As an alternative, you could put your app options into an app.config.json JSON file like this:

{
  "appRoot": "/home/me/projects/myapp",
  "appLocalPath": "index.html",
  "name": "My app",
  "package": "me.myname.myapp",
  "version": "0.0.1"
}

and then, specifying the Android SDK directory using an environment variable, do the same build with:

androidSDKDir=/home/me/android-sdk-linux xwalk_apkgen -o build \
  -x /home/me/xwalk-android/xwalk_app_template \
  --app-config app.config.json

(NB short versions of some command-line options are also available: see --help for details.)

Embedded vs. shared mode

Crosswalk applications can run in one of two modes:

  • Shared mode (the default)

    An application in this mode uses a shared copy of the Crosswalk runtime library. This library has to be installed on the Android system via a platform-specific apk file before the application apk is installed. Note that in this case, the application apk is platform-independent, as it contains no native libraries.

    Note that the Crosswalk runtime library is not available from the Android store, so this mode is only suitable for use by developers, or in situations where the library can easily be made available on the target platform. If a shared mode application is installed on a device without the runtime library, the user will just see a message instructing them to install it.

    If you want to use shared mode, you can find the runtime library apk in the Crosswalk Android distribution. The file you need is apks/XWalkRuntimeLib.apk. Install it with:

    adb install <path to xwalk-android>/apks/XWalkRuntimeLib.apk
    

    (NB adb is the Android SDK installation tool; you will need it on your PATH for the above to work.)

    The generator will build an application in shared mode if you don't specify any architecture. Specify the architecture by setting the arch property (if using the API) or the --arch option (if using xwalk_apkgen).

  • Embedded mode

    An application in this mode includes the Crosswalk runtime inside its apk. Consequently, an embedded mode application is self-contained: it can be installed on an Android device without requiring the runtime library to be installed first. However, embedded mode apk files are platform-specific, unlike shared mode apk files: they will only work on the platform for which they were built.

    The default application mode can be modified by setting the arch property for the application to either x86 or arm. This can be done in the App config if using the API, e.g.:

    {
      "appRoot": "/home/me/projects/myapp",
      "appLocalPath": "index.html",
      "name": "My app",
      "package": "me.myname.myapp",
      "arch": "x86"
    }
    

    or via the --arch command line flag if using xwalk_apkgen:

    xwalk_apkgen --androidSDKDir /home/me/android-sdk-linux \
      --xwalkAndroidDir /home/me/xwalk-android/xwalk_app_template \
      --appRoot /home/me/projects/myapp \
      --appLocalPath index.html \
      --name "My app" \
      --package "me.myname.myapp" \
      --outDir build \
      --arch x86
    

Permissions

Application permissions can be specified by passing a permissions property as part of the App config, e.g.:

{
  "appRoot": "/home/me/projects/myapp",
  "appLocalPath": "index.html",
  "name": "My app",
  "package": "me.myname.myapp",
  "permissions": ["ACCESS_NETWORK_STATE", "INTERNET"]
}

At build time, appropriate permissions are inserted into the AndroidManifest.xml file as permissions on the component; e.g. the above would yield the following elements inside the main <manifest> element:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

The default permissions (if you don't specify any) are:

  • ACCESS_FINE_LOCATION
  • ACCESS_NETWORK_STATE
  • ACCESS_WIFI_STATE
  • CAMERA
  • INTERNET
  • MODIFY_AUDIO_SETTINGS
  • RECORD_AUDIO
  • WAKE_LOCK
  • WRITE_EXTERNAL_STORAGE

The full list of available permissions is on the Android developer website.

Crosswalk extensions

crosswalk-apk-generator supports the inclusion of Java extensions in your apk package. These extensions can expose functionality to an application which is not available from Crosswalk itself. Examples might include using the Android APIs to access music files or photos on the device, or accessing sensors which are not exposed via Crosswalk APIs.

A Crosswalk extension is comprised of:

  • A Java class which subclasses XWalkExtensionClient. This means overriding one or two methods, as shown in the example below.

    package my.extensions.app;
    
    import org.xwalk.app.runtime.extension.XWalkExtensionClient;
    import org.xwalk.app.runtime.extension.XWalkExtensionContextClient;
    
    public class Echo extends XWalkExtensionClient {
      public Echo(String name, String jsApiContent, XWalkExtensionContextClient context) {
        super(name, jsApiContent, context);
      }
    
      @Override
      public void onMessage(int instanceId, String message) {
        postMessage(instanceId, "From java: " + message);
      }
    
      @Override
      public String onSyncMessage(int instanceId, String message) {
        return "From java sync: " + message;
      }
    }
    

    Note that if you only require a synchronous API, you only need to override onSyncMessage(); similarly, if you only want an asynchronous API, just override onMessage().

    You can either pre-bundle your Java classes into .jar files (see below); or include them in crosswalk-apk-generator's build by passing a javaSrcDirs property to the App configuration. This can either be done in an App's JSON configuration file:

    {
      "appRoot": "/home/me/myapp/app",
      "appLocalPath": "index.html",
      "name": "My app",
      "package": "me.myname.myapp",
      "javaSrcDirs": ["/home/me/myapp/extensions/java"],
      ...
    }
    

    Or as a comma-separated string on the xwalk-apkgen command line:

    xwalk_apkgen -o build \
    -a /home/me/android-sdk-linux \
    -x /home/me/xwalk-android/xwalk_app_template \
    --appRoot /home/me/myapp/app \
    --appLocalPath index.html \
    --name "My app" --package "me.myname.myapp" \
    --javaSrcDirs "/home/me/myapp/extensions/java" ...
    
  • Helper Java classes specific to your application. These should be either be included as jar files (see below) or via the javaSrcDirs property (see above).

  • Java jar files containing 3rd party code or your own pre-packaged class files. You can include these via a jars property in the App's JSON configuration file:

    {
      "appRoot": "/home/me/myapp/app",
      "appLocalPath": "index.html",
      "name": "My app",
      "package": "me.myname.myapp",
      "javaSrcDirs": ["/home/me/myapp/extensions/java"],
      "jars": [
        "/home/me/myapp/jars/commons-lang.jar",
        "/home/me/myapp/jars/commons-io.jar"
      ]
    }
    

    Or via a comma-separated list on the command line:

    xwalk_apkgen -o build \
    -a /home/me/android-sdk-linux \
    -x /home/me/xwalk-android/xwalk_app_template \
    --appRoot /home/me/myapp/app \
    --appLocalPath index.html \
    --name "My app" --package "me.myname.myapp" \
    --javaSrcDirs /home/me/myapp/extensions/java \
    --jars "/home/me/myapp/jars/commons-lang.jar,/home/me/myapp/jars/commons-io.jar" \
    ...
    

    Note that if you are building your project using Maven, Ivy or similar, you can just point at jar files and not set javaSrcDirs: compiling your Java classes as part of the apk build is not obligatory.

  • A JavaScript file which calls the Java class's methods, for example:

    var callbacks = [];
    
    extension.setMessageListener(function (msg) {
      // each callback only gets invoked once; we delete it after
      // calling it
      for (var i = 0; i < callbacks.length; i += 1) {
        callbacks[i](msg);
        delete callbacks[i];
      };
    });
    
    exports.echo = function (msg, callback) {
      callbacks.push(callback);
      extension.postMessage(msg);
    };
    
    exports.echoSync = function (msg) {
      return extension.internal.sendSyncMessage(msg);
    };
    

    Note: The above is not a good design for an asynchronous API, as all currently-registered callbacks receive whatever happens to be the next posted message. However, this can only be worked around by adding a lot more complexity (e.g. including a message ID with each message posted to the extension, which is associated with the correct callback for the response). I haven't included that here as it would add too much complexity.

    The JavaScript files for extensions can be maintained in any directory, but it makes most sense if they are separated from the client-side JavaScript code required by your HTML5 app. At build time, they are copied into a directory with a unique generated name, so they don't interfere with or overwrite your client-side code.

  • Configuration to associate JavaScript files with Java classes, and optionally specify extra permissions that extensions need. For example:

    {
      "echo": {
        "class": "my.extensions.app.Echo",
        "jsapi": "xwalk-extensions/js/echo.js",
        "permissions": [
          "...Android permission string...",
          "...Android permission string..."
        ]
      }
    }
    

    This configuration can either be included in the App configuration (if you're using the API), using the extensions property; or it can be put in a JSON file and passed to the xwalk_apkgen tool using the --ext-config option.

    If you use a file, the jsapi paths in the file are resolved relative to the location of the JSON file before use, so that the JavaScript files can be correctly located.

    At build time, a configuration file is generated in assets/extensions-config.json, based on your extensions configuration, but in the format required by Crosswalk. In addition, any permissions you defined for extensions are merged with any application-level permissions; these are then inserted in the generated AndroidManifest.xml file. See the Permissions section (above) for details about the valid permission strings.

Comparison with make_apk.py

Note that this approach to extensions differs from the approach taken by the official Crosswalk make_apk.py script. The official script requires extensions to be placed in directories with a particular structure and naming scheme. It also requires that extensions be packaged into jar files before the apk package can be generated.

By contrast, crosswalk-apk-generator enables a more integrated workflow, allowing you to work on Java code alongside JavaScript code, compile that code, then package any output .class files and 3rd party jar dependencies with the apk in a single step. A complete example of how to structure an application with custom extensions (including the example above) is given in test/functional/app-with-extensions. You can build this application using the test/functional/make-app-with-extensions.test.sh script.

If desired, pre-built extensions (structured the way make_apk.py wants them) could still be added to an apk, by pointing crosswalk-apk-generator at the extension jar files, and writing a JSON configuration to "wire" their Java classes to JavaScript files. For example:

TODO how to use pre-packaged extensions

Using your own keystore

TODO http://developer.android.com/tools/publishing/app-signing.html provides instructions on using keytool

Using the API

Use of the API is documented in HACKING.md.

Contributing

Bugs

TODO

Patches

TODO

Licence

Apache v2; see the LICENCE-APACHE-V2 file in the source for details.

The app provided for testing purposes in test/functional/demo-app is a built version of the SweetSpot game from https://github.com/01org/webapps-sweetspot, released under the Apache v2 license.

The app for demonstrating Android Crosswalk extensions in test/functional/app-with-extensions includes Java jar files from the following projects:

Authors

Elliot Smith (townxelliot)

The original authors of the make_apk.py script (which this work is based on) can be found by looking at the Crosswalk project's AUTHORS file.

deprecated-crosswalk-apk-generator's People

Contributors

thebarge avatar townxelliot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deprecated-crosswalk-apk-generator's Issues

xwalk_apkgen fails on Mac due to ENAMETOOLONG error

  • install crosswalk-apk-generator with npm
  • download current crosswalk release with xwalk_android_dl
  • build web app with xwalk_apk_gen and all mandatory parameters in command line

The error below is produced.

xwalk_apkgen --appRoot . --appLocalPath index.html --name Three --package com.balenet.three --androidSDKDir ~/devel/adt-bundle-mac-x86_64-20131030/sdk/ --xwalkAndroidDir crosswalk-4.32.76.5-x86 --version 1.0

*** STARTING BUILD

*** CHECKING ENVIRONMENT...

*** APPLICATION:
{ name: 'Three',
sanitisedName: 'Three',
pkg: 'com.balenet.three',
icon: '',
fullscreen: true,
theme: 'Theme.Holo.Light.NoActionBar.Fullscreen',
permissions:
[ 'ACCESS_FINE_LOCATION',
'ACCESS_NETWORK_STATE',
'CAMERA',
'INTERNET',
'MODIFY_AUDIO_SETTINGS',
'RECORD_AUDIO',
'WAKE_LOCK',
'WRITE_EXTERNAL_STORAGE' ],
appUrl: null,
appRoot: '.',
appLocalPath: 'index.html',
remoteDebugging: false,
jars: [],
javaSrcDirs: [],
extensions: null,
version: 1,
orientation: null }

*** ENVIRONMENT:
{ java: 'java',
javac: 'javac',
ant: 'ant',
jarsigner: 'jarsigner',
sourceJavaVersion: '1.5',
targetJavaVersion: '1.5',
arch: null,
androidSDKDir: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/',
androidAPILevel: 19,
dx: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/build-tools/android-4.4/dx',
aapt: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/build-tools/android-4.4/aapt',
anttasksJar: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/tools/lib/ant-tasks.jar',
androidJar: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/platforms/android-19/android.jar',
zipalign: '/Users/baleboy/devel/adt-bundle-mac-x86_64-20131030/sdk/tools/zipalign',
xwalkAndroidDir: 'crosswalk-4.32.76.5-x86',
xwalkRuntimeClientJar: 'crosswalk-4.32.76.5-x86/xwalk_app_template/libs/xwalk_app_runtime_java.jar',
xwalkApkPackageAntFile: 'crosswalk-4.32.76.5-x86/xwalk_app_template/scripts/ant/apk-package.xml',
xwalkAssets: null,
xwalkEmbeddedJar: null,
xwalkCoreResources:
{ resDirs: [ 'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/xwalk_core_java/res_grit/' ],
libs: [ 'crosswalk-4.32.76.5-x86/xwalk_app_template/libs_res/runtime/' ],
pkg: 'org.xwalk.core' },
chromiumContentResources:
{ resDirs:
[ 'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/content_java/res_crunched/',
'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/content_java/res_v14_compatibility/',
'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/content_java/res_grit/' ],
libs: [ 'crosswalk-4.32.76.5-x86/xwalk_app_template/libs_res/content/' ],
pkg: 'org.chromium.content' },
chromiumUiResources:
{ resDirs:
[ 'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/ui_java/res_crunched/',
'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/ui_java/res_v14_compatibility/',
'crosswalk-4.32.76.5-x86/xwalk_app_template/gen/ui_java/res_grit/' ],
libs: [ 'crosswalk-4.32.76.5-x86/xwalk_app_template/libs_res/ui/' ],
pkg: 'org.chromium.ui' },
nativeLibs: null,
keystore: 'crosswalk-4.32.76.5-x86/xwalk_app_template/scripts/ant/xwalk-debug.keystore',
keystoreAlias: 'xwalkdebugkey',
keystorePassword: 'xwalkdebug' }

*** LOCATIONS:
{ destDir: '/Users/baleboy/src/threejs/build',
buildJars: [],
jars: [],
assets: [],
resources: {},
nativeLibs: [],
classesDir: '/Users/baleboy/src/threejs/build/classes',
dexFile: '/Users/baleboy/src/threejs/build/classes.dex',
resPackageApk: '/Users/baleboy/src/threejs/build/Three.ap_',
unsignedApk: '/Users/baleboy/src/threejs/build/Three-unsigned.apk',
signedApk: '/Users/baleboy/src/threejs/build/Three-signed.apk',
finalApk: '/Users/baleboy/src/threejs/build/Three.apk',
resDir: '/Users/baleboy/src/threejs/build/res',
assetsDir: '/Users/baleboy/src/threejs/build/assets',
extensionsJsDir: '/Users/baleboy/src/threejs/build/assets/3351e4f0-1395564934779-1xwalk-extensions',
extensionsConfig: '/Users/baleboy/src/threejs/build/assets/extensions-config.json',
srcDir: '/Users/baleboy/src/threejs/build/src',
javaPackageDir: '/Users/baleboy/src/threejs/build/src/com/balenet/three',
androidManifest: '/Users/baleboy/src/threejs/build/AndroidManifest.xml',
defaultDrawableDir: '/Users/baleboy/src/threejs/build/res/drawable',
drawableDirs:
{ xhdpi: '/Users/baleboy/src/threejs/build/res/drawable-xhdpi',
hdpi: '/Users/baleboy/src/threejs/build/res/drawable-hdpi',
mdpi: '/Users/baleboy/src/threejs/build/res/drawable-mdpi',
ldpi: '/Users/baleboy/src/threejs/build/res/drawable-ldpi' } }

*** BUILDING APPLICATION IN /Users/baleboy/src/threejs/build
shell.js: internal error
Error: ENAMETOOLONG, name too long '/Users/baleboy/src/threejs/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets/build/assets'
at Object.fs.mkdirSync (fs.js:642:18)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:57:8)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)
at cpdirSyncRecursive (/usr/local/lib/node_modules/crosswalk-apk-generator/node_modules/shelljs/src/cp.js:72:7)

If androidAPIVersion is not specified, work it out from the Android SDK

We currently require that the androidAPIVersion is specified, and default to '19.0.0'. However, this default is no good if the user doesn't have the tools for that Android SDK version installed.

Perhaps, we could instead infer the most-recent Android API version the user has, and use that. Though we might want to put a lower bound on which versions are acceptable.

"package org.xwalk.app does not exist" when compile the code.

Issue by DonnaWuDongxia from Tuesday Jan 07, 2014 at 11:17 GMT


When I finally get all the environments correct. compile error encounterred:

Error: command
javac -g -d /home/donna/work/wrt/xwalk-apk-generator/build/classes -source 1.5 -target 1.5 -Xlint:unchecked -Xlint:deprecation -classpath /home/donna/adt-bundle/sdk/platforms/android-17/android.jar:/home/donna/Downloads/crosswalk-2.31.27.5-x86/xwalk_app_template/libs/xwalk_app_runtime_client_java.jar /home/donna/work/wrt/xwalk-apk-generator/build/src/me/myname/myapp/My_appActivity.java /home/donna/work/wrt/xwalk-apk-generator/build/src/me/myname/myapp/R.java /home/donna/work/wrt/xwalk-apk-generator/build/src/org/chromium/content/R.java /home/donna/work/wrt/xwalk-apk-generator/build/src/org/chromium/ui/R.java /home/donna/work/wrt/xwalk-apk-generator/build/src/org/xwalk/core/R.java
returned bad code 1
Error output was:
warning: [options] bootstrap class path not set in conjunction with -source 1.5
/home/donna/work/wrt/xwalk-apk-generator/build/src/me/myname/myapp/My_appActivity.java:10: error: package org.xwalk.app does not exist
import org.xwalk.app.XWalkRuntimeActivityBase;
^
/home/donna/work/wrt/xwalk-apk-generator/build/src/me/myname/myapp/My_appActivity.java:12: error: cannot find symbol
public class My_appActivity extends XWalkRuntimeActivityBase {
^
symbol: class XWalkRuntimeActivityBase
/home/donna/work/wrt/xwalk-apk-generator/build/src/me/myname/myapp/My_appActivity.java:16: error: cannot find symbol
super.onCreate(savedInstanceState);
^
symbol: variable super
location: class My_appActivity

though xwalk_android_dl have default arch?

I noticed that I now have to specify an architecture. That seems right for building an apk, but I also have to specify it for the downloader and that doesn't seem quite right, so I thought I'd question it here.

Path to the libs are changing between different versions of xwalk

Issue by DonnaWuDongxia from Tuesday Jan 07, 2014 at 11:09 GMT


Path to the libs are changing between different versions of xwalk, for example:

crosswalk-2.31.27.5-x86/xwalk_app_template/native_libs/libs/x86/libxwalkcore.so
crosswalk-4.32.64.0-x86/xwalk_app_template/native_libs/x86/libs/x86/libxwalkcore.so

crosswalk-4.32.64.0-x86/xwalk_app_template/libs/xwalk_app_runtime_java.jar
crosswalk-2.31.27.5-x86/xwalk_app_template/libs/xwalk_app_runtime_client_java.jar

But xwalk-apk-generator tries to find these libs in some hard-coded path. Then errors are throw when we use unmatched xwalk.

xwalk_android_dl doesn't work when output directed through a pipe

eg :

$ xwalk_android_dl -a arm |& ts
Mar 20 13:30:27 fetching xwalk-android using parameters:
Mar 20 13:30:27   architecture = arm
Mar 20 13:30:27   channel = beta
Mar 20 13:30:27   version = 4.32.76.5
Mar 20 13:30:27   url = https://download.01.org/crosswalk/releases/android-arm/beta/crosswalk-4.32.76.5-arm.zip
Mar 20 13:30:27 starting download of https://download.01.org/crosswalk/releases/android-arm/beta/crosswalk-4.32.76.5-arm.zip
Mar 20 13:30:28 
Mar 20 13:30:28 /home/davidmaxwaterman/z/crosswalk-apk-generator/node_modules/q/q.js:126
Mar 20 13:30:28                     throw e;
Mar 20 13:30:28                           ^
Mar 20 13:30:28 TypeError: Object #<Socket> has no method 'clearLine'
Mar 20 13:30:28     at ConsoleLogger.replace (/home/davidmaxwaterman/z/crosswalk-apk-generator/src/console-logger.js:58:18)
Mar 20 13:30:28     at /home/davidmaxwaterman/z/crosswalk-apk-generator/src/archive-fetcher.js:88:19
Mar 20 13:30:28     at _progressed (/home/davidmaxwaterman/z/crosswalk-apk-generator/node_modules/q/q.js:817:51)
Mar 20 13:30:28     at /home/davidmaxwaterman/z/crosswalk-apk-generator/node_modules/q/q.js:843:24
Mar 20 13:30:28     at /home/davidmaxwaterman/z/crosswalk-apk-generator/node_modules/q/q.js:612:17
Mar 20 13:30:28     at flush (/home/davidmaxwaterman/z/crosswalk-apk-generator/node_modules/q/q.js:108:17)
Mar 20 13:30:28     at process._tickCallback (node.js:415:13)

I'm guessing this is the progress output...perhaps it doesn't make sense when output is directed through a pipe? Note that my real usage is that xwalk_android_dl is part of a script, and I was redirecting the output of the whole script through ts so I could see how long each part takes.

Perhaps it could do with a 'quiet' option?

jar for embedded mode changed name between 5.34.92.0 and 5.34.94.0

The name of the jar file for embedded mode changed from:

xwalk_core_embedded.dex.jar

to

xwalk_runtime_embedded.dex.jar

This prevents embedded mode packaging from working. This needs to be fixed in Env, when looking for Android "pieces".

However, we can't just change the name of the jar file we're looking for, as this will prevent crosswalk-apk-generator from working with version 4 of Crosswalk Android. So we should probably shelve this until we get a chance to look at multi-version support (#5) again.

How to avoid Access-Control-Allow-Origin error on Android?

My web app needs to access the internet and when I used the generator to build the app and run it, it reported Access-Control-Allow-Origin error. It seems it could get around by
setAllowUniversalAccessFromFileURLs(true). Don't know whether there is a configuration param to allow cross-domain access?
The following ticket seemed to disable the Cross-Origin request by default. How can I enable that?
crosswalk-project/crosswalk#791

Apk generated by the tool crashes

Environment

  • OS: Mac OSX
  • Node.js: 0.10.26
  • crosswalk-apk-generator: from npm 0.0.15
  • crosswalk template: 6.35.131.7
  • JDK: 1.7
  • Android SDK platforms installed: 19
  • Phone Android: 4.4.2

Steps

  • CLI
xwalk_apkgen -a <android-sdk> -x <xwalk-dir> --app-url <some-url> --name MyApp --pkg com.my.name --version 0.1 --arch arm
  • The package can be correctly generated in build/MyApp.arm.apk
  • When installed and launched on my phone, the app crashes without any useful message

Python scripts with same parameters can generate correct apk for my phone.

Support other Android manifest elements

Issue by townxelliot from Monday Jan 13, 2014 at 14:05 GMT


See http://developer.android.com/guide/topics/manifest/manifest-element.html for the list.

It should be possible for these to be set for the app, to enable a developer to version their Crosswalk application on the Play store (versionCode is particularly important) or otherwise customise its behaviour.

Alternatively, allow a developer to set their own manifest template location via an app config option.

Path to the libs are changing between different versions of xwalk

Issue by DonnaWuDongxia from Tuesday Jan 07, 2014 at 11:09 GMT


Path to the libs are changing between different versions of xwalk, for example:

crosswalk-2.31.27.5-x86/xwalk_app_template/native_libs/libs/x86/libxwalkcore.so
crosswalk-4.32.64.0-x86/xwalk_app_template/native_libs/x86/libs/x86/libxwalkcore.so

crosswalk-4.32.64.0-x86/xwalk_app_template/libs/xwalk_app_runtime_java.jar
crosswalk-2.31.27.5-x86/xwalk_app_template/libs/xwalk_app_runtime_client_java.jar

But xwalk-apk-generator tries to find these libs in some hard-coded path. Then errors are throw when we use unmatched xwalk.

Update to new download folders

xwalk_android_dl --channel canary doesn't download the latest canary, I assume because of the change in the download folders. I used crosswalk-apk-generator 0.0.13 from NPM.

Refactor logging

Now that we've removed logging almost altogether, we need to come up with a replacement for it (it's too quiet now).

Suggest we have a logger which can toggle between more than two levels of verbosity (was: "lots" or "a ridiculous amount", see #38), so we can cover at least the following (in increasing order of verbosity):

  1. User can see that the build is still continuing (e.g. spinner).
  2. User can see which step the build is at (e.g. "step 1 of 7").
  3. User can see what's happening at the current step and which files are being affected (e.g. "building Java resource file X from directory Y").
  4. User can see the commands which are being run (e.g. "running command XXX took N seconds".

We might want to combine or ignore some of these (e.g. do 1, ignore 2, do 3+4).

Architecturally, it might make sense to have a central hub we can publish events to; then add listeners to the hub which log the events (to the console, a file etc.).

Support Crosswalk manifest.json

Issue by townxelliot from Wednesday Jan 22, 2014 at 10:07 GMT


The current make_apk.py script has a --manifest option which lets you use a manifest to configure the options for the output apk.

xwalk-apk-generator has this partially, but the following would need to be investigated:

  • We use a different format to set the icons for an App instance (we use the Android *dpi values as keys, rather than pixel sizes, as is done in the Crosswalk manifest).

The simplest approach would probably be to use the Crosswalk pixel sizes as keys ("96", "128" etc.), then map those into the correct dpi output apk's res/drawable-* directories.

  • We'd need to see what make_apk.py does with manifest.json once it's processed: is it just included in the apk file, or do its values need to be used to set options in the manifest etc.? My guess is the latter (only app.launch.local_path is supported, for example, so presumably that's being used to set --app-local-path).

Cope better with different/multiple Crosswalk Android versions

Issue by townxelliot from Wednesday Jan 22, 2014 at 09:55 GMT


At the moment, the xwalk_apkgen tool is tailored to a particular Crosswalk Android version (currently: 4.*). This means that it breaks if you try to use it with a different version. (This is because, by design, we try to be selective for the sake of speed, and don't scan for files or include all the .jar or .so files in xwalk_app_template; but this makes the tool brittle if the structure of xwalk_app_template changes.)

There are three ways we could cope with this:

  1. Release different versions of the tool for different Crosswalk Android versions, and make it fail noisily if an unsupported version is used. This is the quick but dirty approach.
  2. Modify the tool to support different Crosswalk Android versions. This would need some kind of map adding to Env.configure() so we can find the right components from Crosswalk Android, depending on the version being used. This would need more coding, but be more flexible and cleaner.
  3. Scan for files rather than try to selectively locate them. This is the current make_apk.py approach. This would be slower and more flexible, but could introduce errors (e.g. if there are files in the xwalk_app_template which should not be in the apk file).

missing aapt.exe

hi

I'm trying to use crosswalk to create simple application for android , I used all Crosswalk instruction to create it , in the section "Building a Crosswalk application " after python make_apk.py I get an error:

There doesn't exist aapt in C:\Development\adt-bundle-windows-x86_64-20140702\sdk.
There doesn't exist aapt.com in C:\Development\adt-bundle-windows-x86_6-20140702\sdk.

Use aapt.exe in C:\Development\adt-bundle-windows-x86_6-20140702\sdk.

I try to move aapt.exe in different folder with no success.

my configurazione on Windows 7:
Android:
[ ] Tools
[x] Android SDK Platform-tools 20
[x] Android SDK Build tools 18.0.1
[ ] Android 4.3 (API 18)
[x] SDK Platform

thanks

shared apk builds but does not run on device

I am trying to build and run a webrtc application using crosswalk apk generatore
I am able to build it but when I try to run it on the device, it fails to detect that the shared library is installed. Am I doing something wrong or failing to specify an option?
I did install via adb on the device "adb install /build/crosswalk-5.32.90.0-arm/apks/XWalkRuntimeLib.apk" before installing and running the built shared apk.

content of the json file build_orcafeb.json
{
"version": "2.0.0",
"permissions": ["ACCESS_NETWORK_STATE", "INTERNET", "ACCESS_WIFI_STATE", "CHANGE_WIFI_STATE", "CHANGE_NETWORK_STATE", "WRITE_EXTERNAL_STORAGE", "CAMERA", "WAKE_LOCK", "RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS", "VIBRATE", "RECEIVE_BOOT_COMPLETED", "WRITE_SETTINGS", "DISABLE_KEYGUARD", "READ_CONTACTS", "WRITE_CONTACTS", "READ_PHONE_STATE", "PROCESS_OUTGOING_CALLS", "CALL_PHONE", "RAISED_THREAD_PRIORITY", "SYSTEM_ALERT_WINDOW"]
}

rm -rf orcafeb;mkdir -p orcafeb
bin/xwalk_apkgen --androidSDKDir /Users/username/android-sdk-macosx
--xwalkAndroidDir build/crosswalk-5.32.90.0-arm/xwalk_app_template
--appRoot projects/orcafeb
--appLocalPath index.html
--name "OrcaFeb"
--package "com.alu.orcafeb"
--nativeLibs "build/crosswalk-5.32.90.0-arm/xwalk_app_template/native_libs/armeabi-v7a/libs/armeabi-v7a/libxwalkcore.so"
--enable-remote-debugging
--arch arm
--mode shared
--icon projects/icon.png
--outDir orcafeb
--app-config build_orcafeb.json

If however I give the following options, the apk compiles fine and works fine but it is using the less desirable embedded mode

rm -rf orcafeb;mkdir -p orcafeb
bin/xwalk_apkgen --androidSDKDir /Users/anand/android-sdk-macosx
--xwalkAndroidDir build/crosswalk-5.32.90.0-arm/xwalk_app_template
--appRoot projects/orcafeb
--appLocalPath index.html
--name "OrcaFeb"
--package "com.alu.orcafeb"
--nativeLibs ""
--enable-remote-debugging
--arch arm
--mode embedded
--icon projects/icon.png
--outDir orcafeb
--app-config build_orcafeb.json

output still too noisy/meaningless

The current output is typically like the following :

>>>>>>> Generating R.java file with aapt
>>>>>>> Generating R.java file with aapt
>>>>>>> Generating R.java file with aapt
>>>>>>> Generating R.java file with aapt
>>>>>>> Compiling classes with javac
>>>>>>> Making intermediate apk for resources in /home/davidmaxwaterman/z/webapps/webapps-mancala/build/Mancala.arm.ap_
>>>>>>> Compiling .class files with dx to generate .dex file in /home/davidmaxwaterman/z/webapps/webapps-mancala/build/classes.dex
>>>>>>> Creating unsigned apk in /home/davidmaxwaterman/z/webapps/webapps-mancala/build/Mancala-unsigned.arm.apk
>>>>>>> Creating signed apk /home/davidmaxwaterman/z/webapps/webapps-mancala/build/Mancala-signed.arm.apk
>>>>>>> Aligning apk file /home/davidmaxwaterman/z/webapps/webapps-mancala/build/Mancala.arm.apk
* DONE
    output apk path is /home/davidmaxwaterman/z/webapps/webapps-mancala/build/Mancala.arm.apk

I realise such statements are perhaps meaningful for someone developing or debugging the generator, but in general use I think they are almost meaningless. Their only utility, imo, is that they show progress. I'd almost prefer no output until 'DONE', and perhaps a generic '|-/' spinner or '%' to show progress. I guess it would make sense if the output was in the form of steps that the user would have to take if they were doing this manually, and phrased as such, even so far as saying 'step 1 of 7: ...' - that'd almost be educational :)
Anyway, it'd be nice to hide any output behind a 'debug', 'verbose', or 'quiet' property.
To satisfy the need for debugging, I kind of liked npm's behaviour where it dumps a log file. Having said that, npm does output some redundant info to stdout/err that tempts the user to not look in the dump file - I'd prefer to simply say - "Something's gone wrong. Please see crosswalk-apk-generator.log."
Anyway, those are my thoughts...not sure about existing logging libraries that can do this sort of thing.

Add link/etc for Java to README

It seems there are several java versions and it's not clear which one the developer needs to install.

Note that I don't seem to have the Java JDK installed, even though I've been successfully(?) generating apks for a while...I do have both /opt/java/64/jre1.7.0_25/ and /usr/lib/jvm/java-7-oracle/, and I'm not sure if these suffice[0]. I suppose it is the need to set $JAVA_HOME that has me looking into this, since I don't have that set in my environment.

So, it leaves me a bit confused. I recognise that setting up java is not really in the scope, but still....

Max.

[0] welcome.html files suggests it is JavaTM Standard Edition Runtime Environment

VersionsFetcher failure message

While developing the grunt task, I noticed that VersionsFetcher was giving quite a cryptic error message when I asked it to download a version that didn't exist. Specifically, it was an arm stable release, and there aren't any (at the time of writing).
I had a look at improving how it fails, but I couldn't quite figure out the promises. This is so this issue isn't forgotten.

Don't add arch to filename when in shared mode

The output apk filename always includes the architecture string ("x86" or "arm") even when building a shared mode apk. It shouldn't.

Suggest we just have APP.apk for architecture-independent apks.

Refactor relationships between Env, App, BuildTools, AppSkeleton

The App/Env split seems to get more and more arbitrary as we go along, and there's not really any need for it. Suggest we replace it with a BuildConfig object instead, which combines all the properties from both in one place.

(We could consider moving the xwalkPieces and androidPieces into separate objects with if the BuildConfig object gets too massive.)

Also suggest that we fix the relationships between Env/App and other components:

  • Remove Env object from the BuildTools constructor (nasty sort-of circular dependency anyway).
  • Remove AppSkeleton object from the Env constructor.
  • Move the Env.build() method to a Builder object, which orchestrates between BuildTools and AppSkeleton.
  • Pass a BuildConfig to the Builder.build() method.

This makes BuildConfig entirely declarative. It also gets rid of some incestuous object relations (e.g. BuildTools is created by Env, but needs Env passed to its constructor). It potentially also makes the Builder reusable (it doesn't have a BuildConfig as part of its state, but has that passed to its build() method).

Better feedback when Finder errors occur during environment check

When validating the environment, the Finder currently looks for files and fails if they aren't found. However, what the Finder looked for and where it looked for it isn't shown; neither is a decent explanation of what was found (e.g. if the Finder failed because multiple candidate files were found, or if it failed because no candidate was found).

This needs some improvement, to make it easier for users to debug when things go wrong.

too many apks

While building the web apps, one problem I have to keep dealing with is to select the 'final' apk from the 3 that are generated in outDir - usually I do 'ls -1 build/*.apk | grep -v signed'.

I find it would be preferable to put all the working files in different place, perhaps to be determined but a --temp arg?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.