Ionic 3 prod release build issue with intellij-core-26.0.1

只谈情不闲聊 提交于 2019-12-02 15:54:08

Seems that the problem started early today.

There's a few things that could work:

The step that worked for me was:

Edit "\platforms\android\CordovaLib\build.gradle" instead "\platforms\android\build.gradle" and put jcenter() after maven… as posted here

repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
}

You can try:

Edit 'platforms/android/build.gradle', you can see more here, as pointed by 'netexpo', here, in the Ionic forum.

allprojects {
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}

Another one:

Posted by MeterMoDev here

Was able to build as well but did the following:

Closed Android Studio also had VS closed. Removed the Android platform. Add the Android platform again. Before running any builds open up the \platforms\android\build.gradle and edit the repositories like @netexpo recommended, and save the file. Open up your project in Android Studio waited for studio do sync the gradle file, it downloaded a couple of items. After the sync process was completed the file had been build.

 repositories {
    mavenCentral()
    maven {
        url "https://maven.google.com"
    }
    jcenter()
}

ionic cordova platform remove android

ionic cordova platform add android@7.0.0

Go to platforms/android/build.gradle

Change this:

jcenter()    
maven {
   url "https://maven.google.com"
}

to

maven {
   url "https://maven.google.com"
}
jcenter()  //Just move this line  

Following on from Ruben Sala's suggestion, that didn't work for me. However, if you edit platforms/android/CordovaLib/build.gradle, and apply the same fix Ruben suggests, it does.

I.e. change:

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

To:

repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()
}

Changing the buildscript section in platforms\android\CordovaLib\build.gradle from

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

to

repositories {
    google()
    jcenter()
}

fixed the issue for me. CLI and AS are building fine now.

I fixed it by editing \platforms\android\build.gradle file (line 39) to this: // Allow plugins to declare Maven dependencies via build-extras.gradle.

 allprojects {
        repositories {
            mavenCentral()
            maven {
                url "https://maven.google.com"
            }
            jcenter()
        }
    }

If anyone is having issues in CI(Jenkins/Travis) instead of making manual changes every time build hook can be handy 😉

create file at config\before_compile_android.js

module.exports = function(ctx) {
    'use strict';
    var fs = ctx.requireCordovaModule('fs'),
        path = ctx.requireCordovaModule('path'),
        deferral = ctx.requireCordovaModule('q').defer(),
        async = require('async');
    var platformRoot = path.join(ctx.opts.projectRoot, 'platforms/android');
    var gradleFiles = [path.join(platformRoot, 'build.gradle'), path.join(platformRoot, 'CordovaLib', 'build.gradle')];
    async.each(gradleFiles, function(f, cb) {
        fs.readFile(f, 'utf8', function(err, data) {
            if (err) {
                cb(err);
                return;
            }
            var result = data;
            if (data.indexOf("maven.google.com") >= 0) {
                console.log("Mirror already present in gradle file.\nSkipping...");
            }else{
                result = data.replace(/jcenter\(\)/g, 'maven{url "https://maven.google.com"}\njcenter()');
            }
            fs.writeFile(f, result, 'utf8', cb);
        });
    }, function(err) {
        if (err) {
            deferral.reject();
        } else {
            deferral.resolve();
        }

    });
    return deferral.promise;
}

and in config.xml configure it for before_compile

<platform name="android">
   <hook src="config/before_compile_android.js" type="before_compile" />
...

p.s. I have not written entire script but modified it to resolve this issue

Try

ionic cordova platform remove android
ionic cordova platform add android@latest

This was for me what ended up working. Nothing else was doing the trick

ps. it installed android 7.1.4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!