Code Monkey home page Code Monkey logo

grunt-phonegap's Introduction

Grunt: Phonegap

A Grunt plugin to provide build tasks for Phonegap applications

Build Status Dependency Status devDependency Status Gittip

NPM

grunt-phonegap integrates Phonegap development with Grunt-based workflows by wrapping the Phonegap 3.0 command line interface.

Rather than polluting the top-level of your project, grunt-phonegap copies your files into a subdirectory containing the Phonegap project, which gets regenerated every time the task phonegap:build is executed.

Jump to Section

Requirements

[Back To Top]

You will need the phonegap CLI tool installed globally to use grunt-phonegap.

npm install phonegap -g

You should also install whatever system dependencies are required by the platforms you intend to target.

For help with that, see Platform Guides from the Phonegap documentation.

Getting Started

[Back To Top]

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Demo

For new apps

The easiest way to start a new project is with the grunt-init-phonegap template.

It will ask you some basic questions and then generate a project skeleton in your current directory.

git clone https://github.com/logankoester/grunt-init-phonegap.git ~/.grunt-init/phonegap
mkdir myapp
cd myapp
grunt-init phonegap

Once the skeleton has generated, open up your new Gruntfile.coffee add one or more platforms to the list.

Your app is ready to build! [Skip to Tasks] to see how.

For existing apps

npm install grunt-phonegap --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-phonegap');

Overview

[Back To Top]

In your project's Gruntfile, add a section named phonegap to the data object passed into grunt.initConfig().

Point phonegap.config.root to the output of your other build steps (where your index.html file is located).

Point phonegap.config.config to your config.xml file.

phonegap.config.cordova should be the .cordova directory that is generated by phonegap create. It must contain a config.json file or your app cannot be built.

Options

grunt.initConfig({
  phonegap: {
    config: {
      root: 'www',
      merges: 'merges', //(Optional) You may specify folder with your platform specific assets
      config: 'www/config.xml',
      cordova: '.cordova',
      cli: 'cordova', // (Optional) Default to `phonegap local`
      html : 'index.html', // (Optional) You may change this to any other.html
      path: 'phonegap',
      cleanBeforeBuild: true // when false the build path doesn't get regenerated
      plugins: [
        '/local/path/to/plugin', 
        'http://example.com/path/to/plugin.git',
        {
          id: 'git://example.com/example/repository',
          variables: [
            {
              name: 'APP_ID',
              value: 'EXAMPLE_ID'
            },
            {
              name: 'CLIENT_KEY',
              value: 'EXAMPLE_KEY'
            }
          ]
        }
      ],
      platforms: ['android'],
      maxBuffer: 200, // You may need to raise this for iOS.
      verbose: false,
      releases: 'releases',
      releaseName: function(){
        var pkg = grunt.file.readJSON('package.json');
        return(pkg.name + '-' + pkg.version);
      },
      debuggable: false,
      // custom properties overriding AndroidManifest.xml
      androidManifest: {
        // properties added to <application>
        application : {
        },
        // properties added to <activity>
        activity : {
          "android:launchMode":"singleTask" // This is necessary to force single app instance.
        }
      },
      // Must be set for ios to work.
      // Should return the app name.
      name: function(){
        var pkg = grunt.file.readJSON('package.json');
        return pkg.name;
      },

      // Add a key if you plan to use the `release:android` task
      // See http://developer.android.com/tools/publishing/app-signing.html
      key: {
        store: 'release.keystore',
        alias: 'release',
        aliasPassword: function(){
          // Prompt, read an environment variable, or just embed as a string literal
          return('');
        },
        storePassword: function(){
          // Prompt, read an environment variable, or just embed as a string literal
          return('');
        }
      },

      // Set an app icon at various sizes (optional)
      icons: {
        android: {
          ldpi: 'icon-36-ldpi.png',
          mdpi: 'icon-48-mdpi.png',
          hdpi: 'icon-72-hdpi.png',
          xhdpi: 'icon-96-xhdpi.png'
        },
        wp8: {
          app: 'icon-62-tile.png',
          tile: 'icon-173-tile.png'
        },
        ios: {
          icon29: 'icon29.png',
          icon29x2: 'icon29x2.png',
          icon40: 'icon40.png',
          icon40x2: 'icon40x2.png',
          icon50: 'icon50.png',
          icon50x2: 'icon50x2.png',
          icon57: 'icon57.png',
          icon57x2: 'icon57x2.png',
          icon60: 'icon60.png',
          icon60x2: 'icon60x2.png',
          icon60x3: 'icon60x2.png',
          icon72: 'icon72.png',
          icon72x2: 'icon72x2.png',
          icon76: 'icon76.png',
          icon76x2: 'icon76x2.png'
        }
      },

      // Set a splash screen at various sizes (optional)
      // Only works for Android and IOS
      screens: {
        android: {
          ldpi: 'screen-ldpi-portrait.png',
          // landscape version
          ldpiLand: 'screen-ldpi-landscape.png',
          mdpi: 'screen-mdpi-portrait.png',
          // landscape version
          mdpiLand: 'screen-mdpi-landscape.png',
          hdpi: 'screen-hdpi-portrait.png',
          // landscape version
          hdpiLand: 'screen-hdpi-landscape.png',
          xhdpi: 'screen-xhdpi-portrait.png',
          // landscape version
          xhdpiLand: 'www/screen-xhdpi-landscape.png'
        },
        wp8: 'SplashScreenImage.jpg',
        ios: {
          // ipad landscape
          ipadLand: 'screen-ipad-landscape.png',
          ipadLandx2: 'screen-ipad-landscape-2x.png',
          // ipad portrait
          ipadPortrait: 'screen-ipad-portrait.png',
          ipadPortraitx2: 'screen-ipad-portrait-2x.png',
          // iphone portrait
          iphonePortrait: 'screen-iphone-portrait.png',
          iphonePortraitx2: 'screen-iphone-portrait-2x.png',
          iphone568hx2: 'screen-iphone-568h-2x.png',
          iphone667h: 'screen-iphone-667h.png',
          iphone736h: 'screen-iphone-736h.png'
        }
      },

      // A list of resources to be copied.
      resources : {
        android : [{
          from : 'phonegap/res/files/android', 
          to   : 'res'}
        ]
      },

      // Android-only integer version to increase with each release.
      // See http://developer.android.com/tools/publishing/versioning.html
      versionCode: function(){ return(1) },

      // Android-only options that will override the defaults set by Phonegap in the
      // generated AndroidManifest.xml
      // See https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
      minSdkVersion: function(){ return(10) },
      targetSdkVersion: function(){ return(19) },

      // iOS7-only options that will make the status bar white and transparent
      iosStatusBar: 'WhiteAndTransparent',

      // If you want to use the Phonegap Build service to build one or more
      // of the platforms specified above, include these options.
      // See https://build.phonegap.com/
      remote: {
        username: 'your_username',
        password: 'your_password',
        platforms: ['android', 'blackberry', 'ios', 'symbian', 'webos', 'wp7']
      },

      // Set an explicit Android permissions list to override the automatic plugin defaults.
      // In most cases, you should omit this setting. See 'Android Permissions' in README.md for details.
      permissions: ['INTERNET', 'ACCESS_COURSE_LOCATION', '...']
    }
  }
})

Dynamic config.xml

[Back To Top]

Beginning with v0.4.1, phonegap.config.config may be either a string or an object.

As a string, the file is copied directly, as with previous versions.

As an object with the keys template<String> and data<Object>, the file at template will be processed using grunt.template.

Example

Gruntfile.js

  // ...
  phonegap: {
    config: {
      config: {
        template: '_myConfig.xml',
        data: {
          id: 'com.grunt-phonegap.example'
          version: grunt.pkg.version
          name: grunt.pkg.name
        }
      }
  // ...

_myConfig.xml

<?xml version='1.0' encoding='utf-8'?>
<widget
  id="<%= id %>"
  version="<%= version %>"
  xmlns="http://www.w3.org/ns/widgets"
  xmlns:gap="http://phonegap.com/ns/1.0">

    <name><%= name %></name>

    <!-- ... -->
</widget>

App Icons

[Back To Top]

If you choose to set phonegap.config.icons with one or more icon sizes, these files will be copied into the appropriate directories to use as your app icon.

You may want to use this feature in conjunction with grunt-rasterize to generate the correctly sized icon files from an SVG source.

Currently this feature supports Android, Windows Phone 8, and iOS.

Example
  phonegap: {
    config: {
      // ...
      icons: {
      	android: {
          ldpi: 'icon-36-ldpi.png',
          mdpi: 'icon-48-mdpi.png',
          hdpi: 'icon-72-hdpi.png',
          xhdpi: 'icon-96-xhdpi.png'
        },
        wp8: {
          app: 'icon-62-tile.png',
          tile: 'icon-173-tile.png'
        },
        ios: {
          icon29: 'icon29.png',
          icon29x2: 'icon29x2.png',
          icon40: 'icon40.png',
          icon40x2: 'icon40x2.png',
          icon50: 'icon50.png',
          icon50x2: 'icon50x2.png',
          icon57: 'icon57.png',
          icon57x2: 'icon57x2.png',
          icon60: 'icon60.png',
          icon60x2: 'icon60x2.png',
          icon60x3: 'icon60x2.png',
          icon72: 'icon72.png',
          icon72x2: 'icon72x2.png',
          icon76: 'icon76.png',
          icon76x2: 'icon76x2.png'
        }
      }
      // ...
    }
  }

versionCode

[Back To Top]

The config-xml documentation from Phonegap Build (the remote build service) indicate that you can set a versionCode for your AndroidManifest.xml file inside your config.xml. However, phonegap just ignores that property.

Google Play will not allow you to upload more than one APK with the same versionCode.

If you set a phonegap.config.versionCode value (function or literal), grunt phonegap:build will post-process the generated AndroidManifest.xml file and set it for you.

In most applications it should simply be an integer that you increment with each release.

See http://developer.android.com/tools/publishing/versioning.html

This option will be ignored for non-Android platforms or when using the remote build service.

Android Debugging

[Back To Top]

When you use phonegap:release to build an apk package for the Android platform, grunt-phonegap will post-process the phonegap-generated AndroidManifest.xml file to set debuggable=false, unless you set the phonegap.config.debuggable option to true.

A debuggable package cannot be published to the Play store. If you want to generate an unsigned, debuggable package for testing on your own devices, you can use the phonegap:debug:android task instead to do this.

This feature exists to ensure we get the intended behavior no matter what Phonegap version you are using. In Phonegap 4.3.x, the release apk is created with debuggable=true regardless of whether a debug certificate was used. In Phonegap 4.4.x, this has been corrected.

minSdkVersion and targetSdkVersion

[Back To Top]

Some Android applications need to force a specific value for minSdkVersion and targetSdkVersion, for example to enable "quirks mode" in Android 4.4's Chrome-based WebView.

Supposedly, Phonegap Build supports this through a config.xml preference like this:

<preference name="android-targetSdkVersion" value="13" />

However, setting this preference appears to have no effect on the output during a local build.

If you set phonegap.config.minSdkVersion and/or phonegap.config.targetSdkVersion, grunt phonegap:build will post-process the generated AndroidManifest.xml file and set it for you.

This option will be ignored for non-Android platforms or when using the remote build service. For remote Android builds, instead try the android-targetSdkVersion preference mentioned above.

Android Permissions

[Back To Top]

If phonegap.config.permissions is omitted, plugin permissions will be set automatically by Phonegap. In most cases, this is what you want.

Ordinarily with Phonegap (local), permissions for the Android platform are written to AndroidManifest.xml based on the requirements of the plugins that you have added to your project, so you do not have to worry about them.

In some (perhaps unusual) situations, you may want to alter these permissions without modifying a plugin.

When you may want to do this:

  • To reserve not-yet-used permissions during development
  • To enable a plugin that does not require the right permissions for your target version of Android
  • While troubleshooting a permissions error in your app.
  • When using an advanced Grunt workflow to set your permissions for different builds dynamically (by specifying phonegap.config.permissions as a function)

If you need this feature, set phonegap.config.permissions to an array of permission basenames, such as ['ACCESS_NETWORK_STATE'].

When phonegap.config.permissions is set, all permissions added by Cordova + plugins will be removed, giving you complete control over the permission manifest.

This means you need to explicitely add any permissions required by plugins, or your app will not work.

Be careful to check any permissions your plugins need before adding this feature to your app, and remember to update it when adding additional plugins later.

If you are using the Phonegap Build cloud service for the Android platform, this setting will have no effect.

Android Screen Orientation

[Back To Top]

If you need to specify the screen orientation for your app on the Android platform, you may set a value for phonegap.config.screenOrientation to cause grunt-phonegap to post-process the generated AndroidManifest.xml and set the correct value for you.

The value can be any one of the following strings:

  • unspecified
  • behind
  • landscape
  • portrait
  • reverseLandscape
  • reversePortrait
  • sensorLandscape
  • sensorPortrait
  • userLandscape
  • userPortrait
  • sensor
  • fullSensor
  • nosensor
  • user
  • fullUser
  • locked

For an explanation of these options, refer to the android:screenOrientation section of in the Android developer guide.

This option will be ignored for non-Android platforms or when using the remote build service.

Application Name

[Back To Top]

If phonegap.config.androidApplicationName is a string or function, then it will be applied to the <application android:name /> attribute in your AndroidManifest.xml.

This option should almost always be left undefined. You will only need to set this if you are implementing a base plugin (a Java class extending from android.app.Application), for example to implement crash reporting with ACRA.

Phonegap Build

[Back To Top]

If you set phonegap.config.remote to a subset of phonegap.config.platforms, those platforms will be built remotely. This is still somewhat experimental, and may not integrate with all local features.

If you use Phonegap Build, you should add your Phonegap App ID to your .cordova/config.json file - otherwise each build will be treated as a new app toward your account quota.

Example: {"lib":{"www":{"id":"phonegap","version":"3.3.0"}}, "phonegap": {"id": 1234567}}

You can find the PhoneGap App ID in your PhoneGap Builds panel.

Tasks

[Back To Top]

phonegap:build[:platform]

Running phonegap:build with no arguments will...

  • Purge your phonegap.config.path
  • Copy your phonegap.config.cordova and phonegap.config.root files into it
  • Add any plugins listed in phonegap.config.plugins
  • ..and then generate a Phonegap build for all platforms listed in phonegap.config.platforms

If you pass a specific platform as an argument (eg grunt phonegap:build:android), the phonegap.config.platforms array will be ignored and only that specific platform will be built.

Note that by default the project will be built with phonegap local but you can switch to cordova, by setting the phonegap.config.cli to cordova. But it won't let you remote build on phonegap build servers.

phonegap:run[:platform][:device]

After a build is complete, the phonegap:run grunt task can be used to launch your app on an emulator or hardware device. It accepts two optional arguments, platform and device.

Example: grunt phonegap:run:android:emulator

If you are using the Android platform, you can see the list of connected devices by running adb devices.

The platform argument will default to the first platform listed in phonegap.config.platforms.

phonegap:release[:platform]

Create a releases/ directory containing a signed application package for distribution.

Currently android is the only platform supported by this task. You will need to create a keystore file at phonegap.config.key.store like this:

$ keytool -genkey -v -keystore release.keystore -alias release -keyalg RSA -keysize 2048 -validity 10000

The keytool command will interactively ask you to set store and alias passwords, which must match the return value of phonegap.config.key.aliasPassword and phonegap.config.key.storePassword respectively.

phonegap:debug[:platform]

Creates a releases/debug directory containing an unsigned application package with debugging enabled.

Currently android is the only platform supported by this task.

By browsing to this APK asset from test hardware device, we can quickly install the APK output from our build. Then we use chrome://inspect to inspect the network traffic as an example - this is not possible using the signed APK.

phonegap:login

Log into the Phonegap Build service with the credentials specified at phonegap.config.remote.username and phonegap.config.remote.password.

phonegap:logout

Log out of the Phonegap Build service.

Running the test suite

[Back To Top]

git clone https://github.com/logankoester/grunt-phonegap.git
cd grunt-phonegap
npm install
git submodule init
git submodule update
grunt

Note that not all tests can be run on all platforms. For example, tests depending on the Windows Phone SDK will be skipped if your OS is detected to be non-Windows.

Contributing

[Back To Top]

Fork the repo on Github and open a pull request. Note that the files in tasks/ and test/ are the output of CoffeeScript files in src/, and will be overwritten if edited by hand.

Likewise, README.md is the output of the grunt docs task, and will be overwritten. README updates should be made in the Markdown files under docs/.

Before running the included test suite, you must first run git submodule update --init on your local clone (see above).

Please run grunt build before submitting a pull request. The build output should be included with your changes.

Release History

[Back To Top]

You can find all the changelogs here.

Latest changelog is from v0.15.2.md:

v0.15.2

  • Adds grunt-init-phonegap project template to make it easier to start new projects
  • Updates async and grunt-contrib-nodeunit dependencies

License

[Back To Top]

Copyright (c) 2013-2014 Logan Koester. Released under the MIT license. See LICENSE-MIT for details.

Bitdeli Badge

xrefs funcs top func library users authors Total views Views in the last 24 hours

grunt-phonegap's People

Contributors

andrewkovalenko avatar arthurgeek avatar ashbrener avatar bendi avatar bitdeli-chef avatar bouzuya avatar deflomu avatar disusered avatar gabrielpoca avatar javarome avatar jsanchezpando avatar kennethkalmer avatar kombucha avatar logankoester avatar mkai avatar pdelorme avatar richardpfisk avatar robwalch avatar shanesmith avatar skarjalainen avatar stephanebachelier avatar

Stargazers

 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

grunt-phonegap's Issues

build:ios fails at PROJECT-NAME-Info.plist

When I am bulding a phonegap project with

grunt phonegap:build:ios

The task stops after [phonegap] adding the iOS platform... with this error:

>> [TypeError: Cannot call method 'replace' of undefined]
   [error] Cannot call method 'replace' of undefined
Fatal error: Unable to read "phonegap/platforms/ios/ember-yeoman-app/ember-yeoman-app-Info.plist" file (Error code: ENOENT).

Is the phonegap:build:ios task supposed to create the xxx-Info.plist file?

iOS build only www

When I build the ios app using 'grunt phonegap:build:ios', the whole ios project is re-generated, is there a way to do like : 'phonegap build ios' and generate only the www files, config.xml... ?

Thanks

Add instructions for local phone gap to read me

Phonegap does not need to be installed globally. With this it is possible to have it installed as a dev dependency:

module.exports = function (grunt) {
    grunt.initConfig({
        env: {
            phonegap: {
                unshift: {
                    PATH: {
                        'value': '../node_modules/.bin',
                        'delimiter': ':'
                    }
                }
            }
        }
        phonegap: {
        ...
    }
    ...
    grunt.loadNpmTasks('grunt-env');
    grunt.loadNpmTasks('grunt-phonegap');

    grunt.registerTask('ios', ['env:phonegap', 'phonegap:build:ios']);
}

Took me a while to figure out so maybe you can add it somewhere.

iOS icons copied to wrong directory

The path is build from...

appName = helpers.config('name');
res = path.join(phonegapPath, 'platforms', 'ios', appName, 'Resources', 'icons');

...but the appName is taken from config whereas the main build copies resources to /platforms/ios/{name taken from config.xml}/Resources

While this could be easily fixed by using the same name property in both places, could it be done in a neater way? The only reason this is an issue for me is that I have the same core code built into several apps with minor config changes and I'd like to avoid having duplicate grunt-phonegap config for each app.

phongap:run:ios emulator doesn't launch

here is my current plugin in config from Gruntfile.js:

phonegap: {
            config: {
                root: '<%= build_dir %>',
                config: {
                    template: 'src/phonegap/_config.xml',
                    data: {
                        id: 'com.test.phonegap.one',
                        version: '<%= pkg.version %>',
                        name: '<%= pkg.name %>'
                    }
                },
                cordova: 'src/phonegap/.cordova',
                path: '<%= build_dir %>/phonegap',
                platforms: ['ios'],
                verbose: false
            }
        }

if i run grunt phonegap:run:ios, i get the following:

Running "phonegap:run:ios" (phonegap:run) task
[phonegap] compiling iOS...
[phonegap] successfully compiled iOS app
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[phonegap] successfully installed onto emulator

if i cd into phonegap.config.path and execute phonegap install ios, i get the same behavior, but if i do the process manually per phonegap instructions:

  • phonegap create...
  • phonegap build ios
  • phonegap install ios

the ios-emulator launches with the app in it...

Can't run phonegap tasks from gruntfile

All of the tasks work great from the command line, but I can't get them to work by calling them from a gruntfile.

For example:

grunt.registerTask('phone', [
    'build',
    'phonegap:bulid:android',
    'phonegap:run:android'
]);

Running grunt phone gives me:

Warning: Task "phonegap:bulid:android" not found. Use --force to continue.

Aborted due to warnings.

Am I missing something?

Add support for remote build, install, run tasks via the Phonegap Build service

Add the following to the config object:

{
  phonegap: {
    config: {
      remote: {
        username: 'username',
        password: 'password',
        platforms: ['android', 'blackberry', 'ios', 'symbian', 'webos', 'wp7']
      }
    }
  }
}

Then add the asks phonegap:login and phonegap:logout, which wrap their respective phonegap commands strings.

remote will be enabled when a task is acting on any platform listed under phonegap.config.remote.platforms.

When remote is enabled, phonegap:build[:platform] will login, use the remote build service, then logout.

When remote is enabled, phonegap:run[:platform] will login, use the remote build service, generate a QRCode in the terminal, then logout.

See also: #26

cordova hook file looses its permission

It seems that directory-copy and cp plugin which this plugin depends have bug of not preserving the permission of file.

For example, I got the build error when I put an executable file in .cordova/hooks/before_build directory complaining Permission denied.

Check this out please.

v2.0 not on NPM

Version 2 isn't on NPM. I have been having some problems with 1.0 and think that 1.0 might solve them but grunt doens't seem to want to pick up packages installed from git. Can you please put v2.0.0 up?

Cheers

Test not completing

I get a ENOENT error when I try to use the plugin or run the tests.

$ grunt
Running "clean:tasks" (clean) task
Cleaning "tasks"...OK

Running "clean:test" (clean) task
Cleaning "test"...OK

Running "copy:test_fixtures" (copy) task
Created 2 directories, copied 1 files

Running "copy:test_cordova" (copy) task
Copied 1 files

Running "coffee:tasks" (coffee) task
File tasks/build.js created.
File tasks/phonegap.js created.
File tasks/run.js created.

Running "coffee:test" (coffee) task
File test/phonegap_build_test.js created.

Running "test" task

Running "phonegap:build" task
Warning: ENOENT, open 'test/phonegap/.cordova/config.json' Use --force to continue.

Aborted due to warnings.

I think the problem is in Build.buildTree: it doesn't create a .cordova folder inside the project folder.

[error] Cannot set property 'is_top_level' of undefined

Just tried for iOS.
if "plugins" is defined in the configuration, you get this error when running "grunt phonegap:build:ios". It creates the ios project but it doesn't compile due to the error.

phonegap version 3.4.0-0.19.7
grunt-phonegap: 0.13.3

Errors during compilation

Hi, sorry to post this here but I don't know where else to request support.

I'm trying to build my app for android (localy) but it fails during the compile step. Here's an extract of the error output:

`-compile:
    [javac] ...\ant-build\classes
    [javac] ...\CordovaLib\src\com\squareup\okhttp\internal\http\HttpsURLConnectionImpl.java:347: method does not override or implement a method from a supertype
    [javac]   @Override public void setFixedLengthStreamingMode(long contentLeng
th) {
    [javac] ...\CordovaLib\src\org\apache\cordova\CordovaWebView.java:297: cannot find symbol
    [javac] symbol  : variable KITKAT
    [javac] location: class android.os.Build.VERSION_CODES
    [javac]                 android.os.Build.VERSION.SDK_INT >= android.os.Build
.VERSION_CODES.KITKAT)
    [javac] 3 errors
>> BUILD FAILED
>> ...\sdk\tools\ant\build.xml:601: The following error occurred while executing this line:
>> ..\sdk\tools\ant\build.xml:720: The following error occurred while executing this line:
>> ...\sdk\tools\ant\build.xml:734: Compile failed; see the compiler error output for details.

I'm using phonegap 3.4 and the android sdk is installed and in my PATH.

If I try to compile my app using the regular phonegap, it works. I also tried compiling a blank project using grunt-init-phonegap but I get th same compilation errors. I've fought through other compialtion errors but at this point I'm a bit clueless and any help would be appreciated.

Thanks, Yannick

Remote build&run with Build.Phonegap tries to create a new app, instead of updating the existent

I have successfully setup phonegap application build with Adobe's cloud, but when I try either to build or run application again with grunt phonegap:build or grunt phonegap:run I get an error "error":"Private app limit reached".

Since I am still only trying out this service, I did not purchase subscription yet. Therefore I have only 1 application slot available. The problem is that when I deploy the same application, it does not update the code base of the current application, but it tries to create a new one.

Cannot able to add plugins via local and remote both

Hi,
I have added following line to my phonegap config data object.
plugins: ['plugins/org.apache.cordova.inappbrowser'],
but while running grunt getting following error message: "Fetching plugin failed: Error: Failed to fetch package information for plugins\org.apache.cordova.inappbrowser"

PS: the InAppBrowser plugin is at plugins folder.

grunt phonegap:build places platforms and plugins in wrong directories

When running this command it adds the plugins and platforms to:

<project-root>/plugins
<project-platform>/plugins

not to

<project-root>/<config:path>/plugins
<project-root>/<config:path>/plugins

This causes the "phonegap build" step to fail with:
Fatal error: Unable to read "phonegap/platforms/android/AndroidManifest.xml" file (Error code: ENOENT).

However, the file is present at "platforms/android/AndroidManifest.xml".

Relevant version info:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

    grunt.initConfig({

        phonegap: {
            config: {
                path: 'phonegap',
                plugins: ['org.apache.cordova.console', 'org.apache.cordova.device', 'org.apache.cordova.statusbar'],
                platforms: ['android'],
            }
        }
    });

Fatal error on: grunt phonegap:release

Hi,

Great work with the project, thanks!!

I am executing: grunt phonegap:release:android . And a fatals error is returning:

-post-build:
Fatal error:      [move] Warning: Could not find file /home/juanan/projects/medessist_frontend/phonegap/platforms/android/ant-build/AndroidManifest.xml to copy.

not sure, but seems as if it was searching in incorrect folder /ant-build instead /bin

Any ideas?

Thanks!
Juan

Automatically include phonegap.js into the projects build.

Hey Logan,

I'm having a hard time figuring out how phonegap.js should be treated with grunt-phonegap. I assume I should refer to it in my index.html

<script stc="phonegap.js"></script>

And the file should be automatically copied to the build directory by either phonegap itself or grunt-phonegap task runner. But it does not happen for some reason. Could you please explain what is going on?

Platforms no longer build under OSX

I believe the change from #69 has stopped any builds on OSX. Specifically, the canBuild method in helpers. If I log out require('platform').os.family I get 'Darwin' but the compatibility array contains 'darwin' (lowercase D) so ._contains is not matching.

The check could be changed to lowercase both the array and the family since I presume there's a reason 'darwin' is in lowercase while Windows and Linux are not - do some systems return it lowercase?

{ [CordovaError: Platform android already added]

I used these settings in my Gruntfile.js:

    phonegap: {
        config: {
            root: 'www',
            config: 'www/config.xml',
            cordova: '.cordova',
            html : 'index.html', // (Optional) You may change this to any other.html
            path: '_build',

            // plugins: [
            // ],

            // platforms: ['android'],

            maxBuffer: 200, // You may need to raise this for iOS.
            verbose: false,
            releases: 'releases',
            releaseName: function () {
                var pkg = grunt.file.readJSON('package.json');
                return ( pkg.name + '-' + pkg.version );
            },
            debuggable: false,

            // Must be set for ios to work:
            name: function () {
                var pkg = grunt.file.readJSON ( 'package.json' );
                return pkg.name;
            },

            // Add a key if you plan to use the `release:android` task:
            // See http://developer.android.com/tools/publishing/app-signing.html
            key: {
                store: 'release.keystore',
                alias: 'release',
                aliasPassword: function () {
                    // Prompt, read an environment variable, or just embed as a string literal
                    return('');
                },
                storePassword: function () {
                    // Prompt, read an environment variable, or just embed as a string literal
                    return('');
                }
            },

            // Set an app icon at various sizes:
            icons: {
                android: {
                    ldpi: 'icon-36-ldpi.png',
                    mdpi: 'icon-48-mdpi.png',
                    hdpi: 'icon-72-hdpi.png',
                    xhdpi: 'icon-96-xhdpi.png'
                },
                wp8: {
                    app: 'icon-62-tile.png',
                    tile: 'icon-173-tile.png'
                },
                ios: {
                    icon29: 'icon29.png',
                    icon29x2: 'icon29x2.png',
                    icon40: 'icon40.png',
                    icon40x2: 'icon40x2.png',
                    icon57: 'icon57.png',
                    icon57x2: 'icon57x2.png',
                    icon60x2: 'icon60x2.png',
                    icon72: 'icon72.png',
                    icon72x2: 'icon72x2.png',
                    icon76: 'icon76.png',
                    icon76x2: 'icon76x2.png'
                }
            },

            // Set a splash screen at various sizes:
            screens: {
                android: {
                    ldpi: 'screen-ldpi-portrait.png',
                    ldpiLand: 'screen-ldpi-landscape.png',
                    mdpi: 'screen-mdpi-portrait.png',
                    mdpiLand: 'screen-mdpi-landscape.png',
                    hdpi: 'screen-hdpi-portrait.png',
                    hdpiLand: 'screen-hdpi-landscape.png',
                    xhdpi: 'screen-xhdpi-portrait.png',
                    xhdpiLand: 'www/screen-xhdpi-landscape.png'
                },
                ios: {
                    ipadLand: 'screen-ipad-landscape.png',
                    ipadLandx2: 'screen-ipad-landscape-2x.png',
                    ipadPortrait: 'screen-ipad-portrait.png',
                    ipadPortraitx2: 'screen-ipad-portrait-2x.png',
                    iphonePortrait: 'screen-iphone-portrait.png',
                    iphonePortraitx2: 'screen-iphone-portrait-2x.png',
                    iphone568hx2: 'screen-iphone-568h-2x.png'
                }
            },

            // Android-only integer version to increase with each release:
            // See http://developer.android.com/tools/publishing/versioning.html
            versionCode: function () { return ( 1 ) },

            // Android-only options that will override the defaults set by Phonegap in the
            // generated AndroidManifest.xml:
            // See https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
            minSdkVersion: function () { return ( 10 ) },
            targetSdkVersion: function () { return ( 19 ) },

            // iOS7-only options that will make the status bar white and transparent
            iosStatusBar: 'WhiteAndTransparent',

            // If you want to use the Phonegap Build service to build one or more
            // of the platforms specified above, include these options:
            // See https://build.phonegap.com/
            // remote: {
            //  username: 'your_username',
            //  password: 'your_password',
            //  platforms: ['android', 'blackberry', 'ios', 'symbian', 'webos', 'wp7']
            // },

            // Set an explicit Android permissions list to override the automatic plugin defaults.
            // In most cases, you should omit this setting. See 'Android Permissions' in README.md for details.
            // permissions: ['INTERNET', 'ACCESS_COURSE_LOCATION', '...']
        }
    },

More info:

"grunt": "^0.4.5",
"grunt-phonegap": "^0.15.2",

Phonegap 3.4

Command: grunt phonegap:build:android

BTW:

I'll be nice to have documentation what all these config settings are doing...

Redundant 'cp' and 'ncp' dependencies?

grunt-phonegap requires both the cp and ncp modules from npm in different places. These modules seem to serve the same purpose, so perhaps we should clean up the references to cp and just use ncp everywhere?

(see also #88)

Editing AndroidManifest.xml

I see we can now specify minSdkVersion and targetSdkVersion but if we want to add X feature to the manifest file? it would be good to specify any property of the file, using something like:

manifest: {
     uses-permission: {
         attts: {
             android:name: "android.permission.INTERNET"
         } 
     }
}

But then it would be better if the project isn't recreated every time we build so we can keep the platforms folders and edit them without losing the changes. What if I want to add a line to the activity class in the Java code?

Release keystore file path can lead to unexpected escaped characters

i.e. if I put my 'release.keystore' above the 'platforms/android' subdirectory (1), path.join(this.config.path, 'platforms', 'android') can return something like '......\release.keystore', which is resolved as a string containing the '\r' character (carriage return), and so a build failing because of an invalid filename '...\phonegap\platforms\android......
elease.keystore'

You probably didn't notice this as using forward slashes on a non-Windows OS.

(1) Why do I want to keep the keystore outside of the android subdirectory? Because it can be deleted/re-generated at each build.

cordova setting

This is more a question than an issue.
Is the cordova setting necessary? what happens when we don't specify the location of a .cordova directory?

Unable to detect emulator listed on adb

On Windows-7 x64 with node 0.10.15 & grunt 0.4.0 with phonegap 3.3.0-0.18.0, I'm unable to run the app on an emulator (Works fine on a device though)

C:\Projects\GKK3>adb devices
List of devices attached
emulator-5554   device


C:\Projects\GKK3>grunt phonegap:run:android:emulator-5554
Running "phonegap:run:android:emulator-5554" (phonegap:run) task
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] installing app onto device
   [error] An error occurred while running the android project.
C:\Projects\GKK3\phonegap\platforms\android\cordova\node_modu
les\q\q.js:126
                    throw e;
                          ^
ERROR: Failed to launch application on device: ERROR: Failed to install apk to d
evice: ERROR: Failed to deploy to device, no devices found.


Done, without errors.

C:\Projects\GKK3>

Running it without an emulator name with grunt phonegap:run, completes successfully but strangely the app isn't installed on the only active emulator (there are no devices attached either):

C:\Projects\GKK3>grunt phonegap:run
Running "phonegap:run" task
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[phonegap] successfully installed onto emulator

Done, without errors.

Edit platform file after build

I have the following problem: After I buid ios I need to open the *.plist file and add some things in order to have my ios bar white.

When you normally run "phonegap build ios" it doesn't replace the file so everything is fine, but since grunt-phonegap destroys the folder I have to manually add the stuff every time.

I don't know if it is an issue that makes sense to the project, but wouldn't it be possible to keep the folder strucutre and just replace the "www" and maybe the plugins? Or is there a reason for the need to destroy the folder?

Remote Build no longer triggering

Prior to 0.13, I would get the following output:

Running "build-phonegap" task

Running "phonegap:build" task
Cleaning ./phonegap-build/
Creating directory tree
Cloning root directory
Cloning .cordova directory
Compiling config.xml
Copying static ./phonegap/config.xml
Adding plugins
Building platforms
Running: phonegap remote build android -V
[phonegap] compressing the app...
[phonegap] uploading the app...
[phonegap] building the app...
[phonegap] Android build complete
No post-build tasks at 'D:\projects\givit-app\node_modules\grunt-phonegap\tasks\build\after\remote\android.js'

Done, without errors.

In 0.13 I get

Running "build-phonegap" task

Running "phonegap:build" task
Skipping platform 'android' (SDK not compatible)
Cleaning ./phonegap-build/
Creating directory tree
Cloning root directory
Cloning .cordova directory
Compiling config.xml
Copying static ./phonegap/config.xml
Adding plugins
Building platforms

Done, without errors.

I would try and fix this myself, but node-inspector is being funny on this machine so I can't step through; and I'm not familiar enough with the source to know exactly where to look.

Android apk is released with debuggable=true

After release and upload to google play I get error that application cannot be added due to this attribute being set. Maybe this could be fixed the same way as 'versionCode'?

I can fix it myself but I'm not sure if adding new "build/after/local" plugin will not break anything.

Sane deprecation of icon config that is not scoped to a platform

A deprecation notice should be displayed when the icon config object contains /(l|m|h|xh)dpi/ properties at the top level, rather than scoped under the android platform.

This is helpful for projects upgrading to v0.7.0 where icon support has been added for multiple platforms (see #19).

cordova binary

I was using cordova with my project but now I had to install phonegap to get the plugin working. I should work with both, right?
Thanks in advance

minSdkVersion for android

I saw in the phongap docs that you can specify several <preference /> tags in the config.xml that are platform specific and one of them is the <preference name="android-minSdkVersion" value="X" /> but it doesn't seem work with grunt-phonegap, I assume it's because of the custom build script?.

Login not working

I've entered a remote, and a platform for remote (iOS). If I run grunt phonegap:build, it prompts me for my username, which is already a bit weird. But when i input it, and press enter, it just skips to a new line without actually logging in. When I do grunt phonegap:login first, I actually see it logging in with the info entered into the remote object without prompting for it, and when i run grunt phonegap:build then, it actually shows "compressing", "uploading" and "building" the app. Any thoughts about what's going on here? Running latest versions of all teh things.

New version doesn't install on android

I've updated to the newest version and everything works except installing on android devices, it compiles but installing always says "no device found". I've looked around and made some diffs but I can't find the problem. Did it happen to someone?

Provide an option to override "android:targetSdkVersion" value in generated AndroidManifest.xml

Some Android applications need to force a specific value for targetSdkVersion, for example to enable "quirks mode" in Android 4.4's Chrome-based WebView.

Supposedly, Phonegap Build supports this through a config.xml preference like this:

<preference name="android-targetSdkVersion" value="13" />

However, setting this preference appears to have no effect on the output during a local build.

This is a similar situation to https://github.com/logankoester/grunt-phonegap#versioncode, and I suggest a similar workaround be provided.

FirefoxOS support

Running grunt phonegap:build with firefoxos as one of the platforms throws up the following warning:

Skipping platform 'firefoxos' (SDK not compatible)

Do not stop on stderr output

Currently the execution of phonegap is stoppen if there is output on stderr. When I build my project there are some errors that are printed but the project just builds fine (like the latest error of phonegap 3.4.0: https://issues.apache.org/jira/browse/CB-6151) So I changed https://github.com/logankoester/grunt-phonegap/blob/master/src/tasks/helpers.coffee#L57 to proc.stderr.on 'data', (err) => grunt.log.error(err). This also gives more detailed error messages that phonegap would like to print but cannot because its killed right after the first line was printed to stderr.

Add a project scaffolding generator

It can be a bit confusing getting started with grunt-phonegap if you did not already start with a Phonegap project, because it is unclear where files like .cordova (for example) are supposed to come from.

This can be done using either a Yeoman generator or grunt-init - I'm leaning toward grunt-init because a Grunt plugin should do things the Grunt Way ™️.

The generator should create the files in the current directory without clobbering existing files.

  • Create a sample Gruntfile.js (or Gruntfile.coffee)
  • Create a package.json (only if none exists)
  • Install (and --save-dev): grunt, phonegap, grunt-phonegap.
  • Create the .cordova directory
  • Create a root directory (default: www)
  • Create a config.xml template
  • Create an empty releases directory

Profile based configuration

Problem

I have two separate directories which I would like grunt-phonegap to use as base directory:

  • source code (dev files with comments that I work with)
  • dist/webapp which I build with another grunt task. It has everything stripped down to 3 files: index.html, package.js and package.css

So, I would like to be able to build an app in debug mode with full source code files being used. I would also like to include weinre debug script there, which I already do with preprocessing my html file, but it requires grunt-phonegap to point to the right directory.
And once I'm ready to make a release and deploy and .apk file, I would like to use my dist/webapp directory, where my assets are as thin as possible.

I don't feel that there's a viable solution with grunt-phonegap at this point to solve this case.

Solution

Profile based configuration (or whatever people like to call it) is pretty much a standard for grunt based plugins nowadays, because of, I assume, it is being straightforward and flexible at the same time. I believe grunt-phonegap would benefit from it as well.

Instead of this:

phonegap: {
    config: {
        // options ...
    }
}

We could have this:

phonegap: {
    options: {
        // Common settings
    }
    ,dev: {
        options: {
            // Settings that are specific for dev environment
        }
        ,someMethod: function() {} // e.g. releaseName
    }
    ,prod: {
        options: {
            // Settings that are specific for production environment
        }
        ,someMethod: function() {} // e.g. releaseName
    }
}

This way we can share common settings and method implementations in general scope and override those on profile level. Profile name is a custom thing that each developer creates for himself. Then, to call a specific setting you need to run the following
grunt phonegap[:profileName][:nextOption][:nextOption]
So you won't have to change your command chain convention, just add one command with the highest priority. If no profile was specified, then :default option should be used.

At the end of the day we would get the following task to build a release version of the app for android
grunt phonegap:dev:release:android
or
grunt phonegap:prod:release:android

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.