Gradle sync failed: CreateProcess error=2, The system cannot find the file specified - build.gradle

I am using android studio 3.0, and i downloaded a project from http://www.androidbootstrap.com and when i import that project it gives me error as "Gradle sync failed: CreateProcess error=2, The system cannot find the file specified".
This type of question and respective answers already posted but non of them solve my problem due to this reason i am posting this question please understand this.
the Gradle Script>build.gradle is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
jcenter()
}
}
and app\build.gradle is:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'io.fabric.tools:gradle:1.19.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
maven { url 'https://github.com/donnfelker/mvn-repo/raw/master/' }
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
def computeVersionCode() {
if (System.env.BUILD_NUMBER) { // Check if there is a system build number.
return "$System.env.BUILD_NUMBER".toInteger()
} else if (System.env.CIRCLE_BUILD_NUM) { // Check to see if this is built on circle CI
return "$System.env.CIRCLE_BUILD_NUM".toInteger()
} else {
return 1 // if none is found, default to 1.
}
}
def computeVersionName() {
return "1." + computeVersionCode()
}
//noinspection GroovyUnusedAssignment
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
android {
compileSdkVersion 23
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 18
targetSdkVersion 23
versionCode computeVersionCode()
versionName computeVersionName()
// Enable this if you want to use Build.GIT_SHA in your code somewhere.
// This will give you the last GIT_SHA that was committed
// buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'LICENSE.txt'
}
signingConfigs {
// Uncomment and set values and then this will work
// release {
// storeFile file(System.getenv('ANDROID_KEYSTORE_PATH'))
// storePassword System.getenv('ANDROID_STORE_PASS')
// keyAlias System.getenv('ANDROID_KEY_ALIAS')
// keyPassword System.getenv('ANDROID_KEY_PASS')
// }
}
lintOptions {
abortOnError false
}
buildTypes {
debug {
applicationIdSuffix '.debug'
minifyEnabled false
// zipAlign false // this is default for debug
}
release {
// minifyEnabled true
// proguardFile '..\proguard.cfg'
// signingConfig signingConfigs.release
// zipAlign true // this is default for release
// testPackageName 'example.com.tests'
// testInstrumentationRunner 'android.test.InstrumentationTestRunner' // this is the default
}
}
}
dependencies {
// Android Support Libs
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.code.gson:gson:2.3'
// Dependency Injection
compile 'com.google.dagger:dagger:2.0'
// View Injection
compile 'com.jakewharton:butterknife:7.0.1'
// Logging
compile 'com.jakewharton.timber:timber:3.0.2'
compile 'com.actionbarsherlock:viewpagerindicator:2.4.1'
compile 'com.nineoldandroids:library:2.4.0'
// Event Bus
compile 'com.squareup:otto:1.3.5'
// Image Loading
compile 'com.squareup.picasso:picasso:1.1.1'
// HTTP
compile 'com.squareup.retrofit:retrofit:1.5.1'
// Fabric/Crashlytics
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar') {
transitive = true
}
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.4'
// Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
// Contrib
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
// http://stackoverflow.com/a/30931887/5210
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
// Set this dependency to build and run UI Automator tests
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'javax.annotation:jsr250-api:1.0'
}

Try instead proxy settings of your project.

Related

Unresolved reference: antlr

When I am importing antlr, as in below
import org.antlr.v4.runtime.*
...
I get the error message saying Unresolved reference: antlr.
Not quite sure if you need this info, but my build.gradle is currently as follows:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.intellij' version '1.2.1'
id 'java'
}
group 'me.ylee'
version '1.0-SNAPSHOT'
repositories {
google()
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.21"
implementation "net.java.dev.jna:jna:5.11.0"
// Dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
intellij {
plugins = ['Kotlin', 'java']
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
How can I successfully import the antlr? Do I need to include antlr somewhere in the build.gradle?
Any help would be appreciated!
I have figured it out. I realized I needed to add antlr-related dependencies as shown in the revised build.gradle as shown below:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.intellij' version '1.2.1'
id 'java'
id 'antlr'
}
group 'me.ylee'
version '1.0-SNAPSHOT'
repositories {
google()
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.21'
implementation "net.java.dev.jna:jna:5.11.0"
antlr 'org.antlr:antlr4:4.10.1'
implementation 'org.antlr:antlr4-runtime:4.10.1'
// Dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
intellij {
plugins = ['Kotlin', 'java']
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}

Could not resolve com.squareup.sqldelight:native-driver:1.3.0

I am trying to build a Kotlin multiplatform project to serve as a shared module for iOS and Android app. I am trying to integrate SQLDelight but I am stuck with this error while syncing Gradle. The following are the error and the build.gradle file respectively.
Error
Could not resolve com.squareup.sqldelight:native-driver:1.3.0.
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at
https://docs.gradle.org/current/userguide/declaring_repositories.html
build.gradle
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.squareup.sqldelight:gradle-plugin:1.3.0'
}
}
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.72'
}
repositories {
mavenCentral()
jcenter()
google()
}
group 'com.example'
version '0.0.1'
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'maven-publish'
def ktor_version = '1.3.2'
kotlin {
jvm()
// This is for iPhone simulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework()
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:1.3.0"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation kotlin('stdlib')
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "com.squareup.sqldelight:sqlite-driver:1.3.0"
}
}
jvmTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
dependencies {
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:1.3.0"
}
}
iosTest {
}
}
}
configurations {
compileClasspath
}
I removed the
implementation "com.squareup.sqldelight:native-driver:1.3.0" from commonMain's dependecies.
It worked.
Working build.gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.squareup.sqldelight:gradle-plugin:1.3.0'
}
}
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.72'
}
repositories {
mavenCentral()
jcenter()
google()
}
group 'com.example'
version '0.0.1'
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'maven-publish'
def ktor_version = '1.3.2'
kotlin {
jvm()
// This is for iPhone simulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework()
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation kotlin('stdlib')
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "com.squareup.sqldelight:sqlite-driver:1.3.0"
}
}
jvmTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
dependencies {
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:1.3.0"
}
}
iosTest {
}
}
}
configurations {
compileClasspath
}

foundation-sites 6 replacing panini for jekyll

I'm looking to extend a zurb foundation for sites 6 site and use jekyll instead of panini to render the HTML. I'm using the out of the box ZURB foundation prototype template that includes ES6 + webpack. I want foundation to handle all the SASS and JS compiling and I also want to retain the browsersync functionality. I just want to know the best approach for modifying the gulp file to integrate jekyll, this is so I can work with GitHub Pages.
Here is what the default gulp.babel.js file looks like:
'use strict';
import plugins from 'gulp-load-plugins';
import yargs from 'yargs';
import browser from 'browser-sync';
import gulp from 'gulp';
import panini from 'panini';
import rimraf from 'rimraf';
import sherpa from 'style-sherpa';
import yaml from 'js-yaml';
import fs from 'fs';
import webpackStream from 'webpack-stream';
import webpack2 from 'webpack';
import named from 'vinyl-named';
// Load all Gulp plugins into one variable
const $ = plugins();
// Check for --production flag
const PRODUCTION = !!(yargs.argv.production);
// Load settings from settings.yml
const { COMPATIBILITY, PORT, UNCSS_OPTIONS, PATHS } = loadConfig();
function loadConfig() {
let ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
}
// Build the "dist" folder by running all of the below tasks
gulp.task('build',
gulp.series(clean, gulp.parallel(pages, sass, javascript, images, copy), styleGuide));
// Build the site, run the server, and watch for file changes
gulp.task('default',
gulp.series('build', server, watch));
// Delete the "dist" folder
// This happens every time a build starts
function clean(done) {
rimraf(PATHS.dist, done);
}
// Copy files out of the assets folder
// This task skips over the "img", "js", and "scss" folders, which are parsed separately
function copy() {
return gulp.src(PATHS.assets)
.pipe(gulp.dest(PATHS.dist + '/assets'));
}
// Copy page templates into finished HTML files
function pages() {
return gulp.src('src/pages/**/*.{html,hbs,handlebars}')
.pipe(panini({
root: 'src/pages/',
layouts: 'src/layouts/',
partials: 'src/partials/',
data: 'src/data/',
helpers: 'src/helpers/'
}))
.pipe(gulp.dest(PATHS.dist));
}
// Load updated HTML templates and partials into Panini
function resetPages(done) {
panini.refresh();
done();
}
// Generate a style guide from the Markdown content and HTML template in styleguide/
function styleGuide(done) {
sherpa('src/styleguide/index.md', {
output: PATHS.dist + '/styleguide.html',
template: 'src/styleguide/template.html'
}, done);
}
// Compile Sass into CSS
// In production, the CSS is compressed
function sass() {
return gulp.src('src/assets/scss/app.scss')
.pipe($.sourcemaps.init())
.pipe($.sass({
includePaths: PATHS.sass
})
.on('error', $.sass.logError))
.pipe($.autoprefixer({
browsers: COMPATIBILITY
}))
// Comment in the pipe below to run UnCSS in production
//.pipe($.if(PRODUCTION, $.uncss(UNCSS_OPTIONS)))
.pipe($.if(PRODUCTION, $.cleanCss({ compatibility: 'ie9' })))
.pipe($.if(!PRODUCTION, $.sourcemaps.write()))
.pipe(gulp.dest(PATHS.dist + '/assets/css'))
.pipe(browser.reload({ stream: true }));
}
let webpackConfig = {
rules: [
{
test: /.js$/,
use: [
{
loader: 'babel-loader'
}
]
}
]
}
// Combine JavaScript into one file
// In production, the file is minified
function javascript() {
return gulp.src(PATHS.entries)
.pipe(named())
.pipe($.sourcemaps.init())
.pipe(webpackStream({module: webpackConfig}, webpack2))
.pipe($.if(PRODUCTION, $.uglify()
.on('error', e => { console.log(e); })
))
.pipe($.if(!PRODUCTION, $.sourcemaps.write()))
.pipe(gulp.dest(PATHS.dist + '/assets/js'));
}
// Copy images to the "dist" folder
// In production, the images are compressed
function images() {
return gulp.src('src/assets/img/**/*')
.pipe($.if(PRODUCTION, $.imagemin({
progressive: true
})))
.pipe(gulp.dest(PATHS.dist + '/assets/img'));
}
// Start a server with BrowserSync to preview the site in
function server(done) {
browser.init({
server: PATHS.dist, port: PORT
});
done();
}
// Reload the browser with BrowserSync
function reload(done) {
browser.reload();
done();
}
// Watch for changes to static assets, pages, Sass, and JavaScript
function watch() {
gulp.watch(PATHS.assets, copy);
gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, browser.reload));
gulp.watch('src/{layouts,partials}/**/*.html').on('all', gulp.series(resetPages, pages, browser.reload));
gulp.watch('src/assets/scss/**/*.scss').on('all', sass);
gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(javascript, browser.reload));
gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
gulp.watch('src/styleguide/**').on('all', gulp.series(styleGuide, browser.reload));
}
I assume as part of the jekyll build/rebuild I would need to use the keep-files config setting so when jekyll clobbers the output directory file don't get overwritten.
Appreciate any help
Thanks
Jekyll is a different solution than Panini and uses Ruby
https://jekyllrb.com/docs/installation/
In general you might need some git hook or Travis config.
https://github.com/DanielRuf/testblog/blob/source/.travis.yml
https://github.com/DanielRuf/testblog/blob/source/Rakefile

Aurelia bundle all jspm dependencies automatically

I'm trying to automatically bundle all jspm dependencies --so I don't have to maintain a manual list-- with a gulp task:
var gulp = require('gulp');
var bundler = require('aurelia-bundler');
var package = require('../../package.json');
var jspmDeps = Object.keys(package.jspm.dependencies);
var config = {
force: true,
baseURL: '.',
configPath: './system.config.js',
bundles: {
"output/jspm": {
"includes": jspmDeps,
"options": {
"minify": false,
"inject" : true
}
}
}
};
gulp.task('build-jspm', function () {
return bundler.bundle(config);
});
Unfortunately, this isn't picking up and bundling all sub-dependencies of the modules included in the bundle. Quite a few dependencies are dynamically loaded by aurelia, which don't get detected during bundling.
Is there a way to force aurelia-bundler (or jspm-cli) to bundle the entire dependency tree from jspm?
[Update] Turns out jspm's bundler has the same behavior, in that it won't bundle modules unless it detects a call to import 'some-sub-dependency'; there are plans to trace dynamic loading at some point

Run eslint before watchify runs

I'm adding watchify to our build process but I want to put a precondition to watchify running, and that is that the file(s) that changed pass our linting step (which is using ESLint).
I was thinking of doing this:
function runBrowserify(watch){
var babel = babelify.configure({
optional: ['es7.objectRestSpread']
});
var b = browserify({
entries: './app/main.js',
debug: true,
extensions: ['.jsx', '.js'],
cache: {},
packageCache: {},
fullPaths: true
})
.transform(babel);
if(watch) {
// if watch is enable, wrap this bundle inside watchify
b = watchify(b);
b.on('update', function(ids) {
//run the linting step
lint(ids);
//run the watchify bundle step
gutil.log(gutil.colors.blue('watchify'), 'Started');
bundleShare(b);
});
b.on('time', function (time) {
gutil.log(gutil.colors.blue('watchify'), 'Finished', 'after', gutil.colors.magenta(time), gutil.colors.magenta('ms'));
});
}
bundleShare(b);
}
function bundleShare(b) {
b.bundle()
.pipe(source('main.min.js'))
.pipe(gulp.dest('./dist'));
}
function lint(glob) {
return gulp.src(glob)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
}
The problem is that the linting step is async so it doesn't finish before the bundling would be done (it also throws so I probably need to use plumber to stop it from terminating the watch step).
So how would I make a precondition before I call bundleShared?
I was able to do this using the closure method I mentioned above. I also moved my Browserify and Watchify code into helper functions that each build could take advantage of.
gulpfile.js (partial)
gulp.task('build:dev', buildDev);
gulp.task('lint:js', lintJS);
function lintJS(callback) {
return gulp.src(['src/**/*.js', 'src/**/*.jsx', '!src/js/vendor/**/*.*',])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function buildDev(callback) {
var bundler = getBundler('src/js/app.jsx', { debug: true }, callback);
var watcher = getWatcher(bundler, rebundle);
function rebundle() {
lintJS(callback);
return watcher.bundle()
.pipe(source('bundle.min.js'))
.pipe(buffer())
.pipe(gulp.dest('dist/js'));
}
rebundle();
// Call watch methods here, i.e.: watchHTML()
return callback();
}
/****************************** Helper functions ******************************/
/**
* Gets the default Browserify bundler used by all builds.
*
*
* #param path A string representing where Browserify should start from
* #param options An Object containing options for the bundler
* #param callback The Gulp callback function from the calling task
* #return A basically configured Browserify bundler
*/
function getBundler(path, options, callback) {
var bundler = browserify(path, { debug: options.debug, cache: {}, packageCache: {} });
bundler.transform(babelify);
bundler.on('log', gutil.log);
bundler.on('error', gutil.log.bind(gutil.colors.red, 'Browserify Error'));
return bundler;
}
/**
* Gets the default Watchify watcher used by dev builds. By default, the watcher
* will rebundle the Browserify package when an update occurs.
*
* #param bundle The Browserify bundler object
* #param rebundle A function to perform when Watchify detects a code update
* #return A basically configured Watchify watcher
*/
function getWatcher(bundle, rebundle) {
var watcher = watchify(bundle);
watcher.on('update', rebundle);
return watcher;
}
For my test and prod builds, I don't use Watchify (and thus have no rebundle() method) so I keep the 'lint:js' task as a dependency:
gulp.task('build:test', ['lint:js'], buildTest);
gulp.task('build:prod', ['lint:js'], buildProd);