Android O Gradle build fails with travis ci - android

I'm trying to use Travis CI for my Android Project but my Builds constantly failing but works on local build. I am using Android Studio Preview 3 and gradle 3 alpha 3.
I am getting this error below.
Could not find com.android.tools.build:gradle:3.0.0-alpha3.
Here is my build log
My Travis Config file
My Project gradle file

I'm getting an Access denied error to your build log, and I didn't use it, but I'll try to answer you.
As announced here:
The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.
You can try to fix it by adding Google’s Maven Repository here like this:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
As commented here, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
Also be sure to update build tools to the latest version as suggested in this related question:
Update your build tools from SDK manager
I add links to samples using the new sdkmanager command line here.
I would need a sample project reproducing the issue to check my suggestions.

Related

Error: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25 in Ionic 3

I am getting the following error suddenly while building Ionic 3 app for Android.
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25
We have one solution from Android Studio here but after I did change in my build.gradle with the following code I am still getting the error.
buildscript {
repositories {
...
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
allprojects {
repositories {
...
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
My build.gradle file looks like this after I updated my Cordova and added the above solution.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
//This replaces project.properties w.r.t. build settings
project.ext {
defaultBuildToolsVersion="28.0.3" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Still the same error.
The problem lies in the cordova-support-google-services plugin for Cordova.
This plugin's build.gradle looks like this as of today (October 24th, 2019):
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
}
More exactly the problem lies in this dependency:
classpath 'com.android.tools.build:gradle:+'
That is an extremely brittle way of specifying dependencies. The '+' sign here means "fetch the most recent version available in the repo".
If a newer version is published in the repo, and it breaks the build, then everyone with this plugin has their projects broken.
This happened today. The broken version that is being fetched is com.android.tools.build:gradle:4.0.0. It requires some Kotlin stuff.
That is why you need to ALWAYS freeze dependencies to reliably build your project. Never trust the newer stuff. This dependency compiles fine just as it did yesterday:
classpath 'com.android.tools.build:gradle:3.5.1'
For those using Cordova or Ionic, you can make a quick fix to be able to build the project by freezing the dependency in the file:
<projectroot>/platforms/android/cordova-support-google-services/<project>-build.gradle
This is not a definitive solution though. If you reinstall the android platform via Cordova the error will show up again. The project maintainer should either freeze the dependency or fix it to support gradle 4.0.0.
In the meantime just use a fixed fork of this plugin.
EDIT 10/28/19:
cordova-support-google-services was updated today to version 1.3.2 which changes the classpath from
classpath 'com.android.tools.build:gradle:+'
to
classpath 'com.android.tools.build:gradle:3.+'
which seems to fix the kotlin error
Original Answer
I got mine to build successfully by doing the following:
I edited
platforms->android->cordova-support-google-services->myAppName-build.gradle
and changed
maventCentral()
to
maven { url "https://maven.google.com" }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
That solved the kotlin error then I was getting a different error that I resolved by changing
classpath 'com.google.gms:google-services:4.2.0'
to
classpath 'com.google.gms:google-services:4.1.0'
It then built successfully.
Here is the solution.
The problem was exactly the maven repository (here), but the issue was with the build.gradle from the cordova-support-google-services plugin, so I added the required line and everything is ok now, I've already created a pull request to the original repo (here). But in the meantime you can do what I did, just replace in the package.json the current versión with my repo:
Before:
...
"cordova-support-google-services": "^1.3.1",
...
After:
...
"cordova-support-google-services": "https://github.com/LuisEGR/cordova-support-google-services.git",
...
after that you will have to:
Remove folders platforms and plugins
run npm install
This is a temporal solution while the pull request to the main repo gets accepted and the npm package updated
and that's it, now you can build your project again.
I'm using Ionic 4, and some plugins require cordova-support-google-services, in case you don't have it in your package.json the error could be with another plugin, if so please add the package.json so we can find out which one is the problem.
UPDATE 24/OCT:
I've changed the solution in my repo as many of you suggested, now the solution consinst just in fixing the dependency: from: com.android.tools.build:gradle:+ to classpath com.android.tools.build:gradle:3.+, this is already in my repo if you want to see what's changed
in my project i fix like this.(my project in kotlin)
buildscript{
repositories {
google()
jcenter()
......
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
allprojects {
repositories {
google()
jcenter()
......
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
Solution for ionic v3 and cordova
#Mister Smith solution solved my problem
you have to go to the file
platforms/android/cordova-support-google-services
then
Replace
classpath 'com.android.tools.build:gradle:+'
by
classpath 'com.android.tools.build:gradle:3.5.1'
#Alternative solution I have found is to
setup kotlin in your system :)
As a further temporary fix to follow-up on the suggestion from #MisterSmith, use a hook to re-apply the lock:
<hook src="scripts/fix_android_dep.sh" type="after_platform_add"/>
with this overly wordy bash code:
#!/usr/bin/env bash
## temporary fix for android studio EAP issue
## SOURCE: https://stackoverflow.com/a/58536638/56545
if [ -d "platforms/android/cordova-support-google-services" ]; then
file="platforms/android/cordova-support-google-services/app-build.gradle"
from="classpath 'com.android.tools.build:gradle:+'"
to="classpath 'com.android.tools.build:gradle:3.5.1'"
change=`sed "s/$from/$to/" < "$file"`
echo "$change" > "$file"
fi
I had to add maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } both into the top-level build.gradle and into the app module build.gradle.
In both cases both into the buildscripts.repositories and in allprojects.repositories
None of the above worked for me. I ended up removing the google-services plugin and add it.
cordova plugin rm cordova-support-google-services
cordova plugin add cordova-support-google-services
In my case I had the same error first, then a whole bunch of other packages (org.ow2.asm:asm-analysis:4.0#jar, etc...) that could also not be resolved.
The problem was that I upgraded Gradle to v5 (to be able to support the new version of Crashlytic). Doing so, I upgraded the repository to Google(), and deleted the old maven { url ... } entries.
But I also deleted jcenter(), which was still required for a lot of nodes.
Now my repository section looks like this:
buildscript {
repositories {
maven { url "$rootDir/../node_modules/react-native/android" }
google() // Google Maven repository
jcenter()
}
//...
So if someone else is reading this but was not happy with the current accepted solution of downgrading Gradle, check if you have jcenter().
Ps.: I realize this is an old issue but I recently found it while searching on google.

Android Studio 3.2 - Could not find com.android.tools.build:aapt2:3.2.0-4818971

I was following a tutorial to develop icon pack for android and when I imported the project I got several errors and it was solved here - Gradle Version 4.6 - Absolute path are not supported when setting an output file name
After solving that error, the following error poped up.
Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
Required by:
project :licensing
I tried to open the URLs and I was able to download JAR (aapt2-3.2.0-4818971-windows.jar) and JSON (aapt2-3.2.0-4818971.pom.json) files from the first 2 URLs. Should I copy these files somewhere? What should I do to solve this error?
Most likely you do not have the Google repository in your project's build.gradle file. Add google() in BOTH locations as shown below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I was able to solve the issue by adding google() in both locations:
File -> Project Structure -> Project -> *Now add ", google()" in
Android Plugin Repository
and
Default Library Repository
*
When you upgrade to 4.6 version of gradle. You need following upgrades too. Gradle Plugin Release page.
1. Android Studio 3.+
You need Android Studio version 3.+ to have 4.6 version of gradle. At the time of post latest release was 3.2.1. You can see latest release on this page.
2. Gradle Plugin 3.1.+
You need 3.1.+ gradle plugin for gradle-4.6 support. Check in project level build.gradle.
classpath 'com.android.tools.build:gradle:3.2.1'
At the time of post latest version was 3.2.1. You can see latest release here.
3. Add Google Maven Library
You need to add Google Maven library to project level build.gradle like below code.
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
...
}
}
allprojects {
repositories {
google()
...
}
}
see the dependencies of module :licensing and use com.android.tools.build:aapt2:3.2.0 (or even "com.android.tools.build:aapt2:3.2.0:windows") there, which is the final version ...that 4818971 version should ordinary come with an alpha prefix/suffix (the version number seems to be incorrect). maybe adding repository google() might be required, too. ordinary, that dependency should be present; removing that dependency might be another possible option.
For those people who still face exactly the same problem even after adding two google to BOTH positions in relevant gradle file.I would suggest you to check Android Studio -> Preferences -> HTTP Proxy page.
If you find it says some warnings like "...have set JVM proxy to 127.0.0.1".Then you should consider vpn-related issues which depends on your context.
If your desktop is MacOS, then go to Network setting page, advance->proxy tab,uncheck all the checkbox there.
Back to your IDE as following steps: Android Studio->File->Invalidate Caches/Restart.After that,go back to check Android Studio -> Preferences -> HTTP Proxy page again,previous warnings should be gone.Run again.
I solved my issue by upgrading my classpath from
'com.google.gms:google-services:4.0.0
to
'com.google.gms:google-services:4.2.0'
hope this helps

Ionic3 Build-Error: Could not find play-services-auth-base.aar (15.0.1)

i have a bigger Ionic3 project running and did not do any changes since i had a successful build last time. Today, i tried to build again, getting the error:
Could not find play-services-auth-base.aar (com.google.android.gms:play-services-auth-base:15.0.1).
I can not figure out why this happens. Cordova-platform is Version 6.3.0.
Steps done so far:
Installed cordova-android-play-services-gradle-release, which 15.+ as version during the build
Installed cordova-android-support-gradle-release, which 27.+ as version during the build
Manipulated gradle.build within the platform, as recommended in other stackoverflow-questions.
Maybe updating cordova to 7.x also is an option, but i want to avoid it due to multiple cordova plugin dependencies.
Code:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
There is currently something wrong with the jcenter() repository. I guess they will fix that soon.
Anyway, for the most packages a fix could be to add the google() repository at the first position in the build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
}
allprojects {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
It's important that google() is listed before jcenter().
If your app does not require any of the newer Google APIs, try specifying an older Play Services Version in your config.xml file. I got a successful build by using 11.6.2. Anything newer gave me the same build error.
According to this: https://developer.android.com/topic/libraries/support-library/setup
if you're using a version of Gradle lower than 4.1, you must use
maven { url 'maven.google.com'; }
instead of
google()
As far as I can see, this error may also occur, when Google or anyone else marks the repository "google-cache" as "blacked-out". Then instead of getting the library you want, you'll get a json string representig that error. It seems that this is enough information for Android Studio to say "OK, found a library entry, but its not there", so the build will fail. google() or maven() should then provide a backup entry, but because jcenter() was the first repository in the list and has given a "proper answer" of the request gradle won't ask the other repos for a solution.
As #Manuel already posted, just put the google() repo before jcenter() in your projects build.gradle.

CI server error: Could not find method google() for arguments [] on repository container

I'm aware that this error can be caused by using old versions of Gradle and the Android Gradle plugin, but in this case this build error only occurs on the remote cloud-based CI server (Nevercode) and not locally (either in Android Studio, or command line). The project is using recent versions of both. This appears to be a different cause to that mentioned in other questions about this error.
gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
root build.gradle:
buildscript {
repositories {
jcenter()
google() // <-- Error points to (line 7) here
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
google()
flatDir {
dirs 'libs'
}
}
}
Build error:
Could not find method google() for arguments [] on repository container.
/build.gradle' line: 7
Gradle cannot find the definition of google() but this should work with Gradle 4.0+ and Android Gradle plugin v3.0+ according to this Error:(6, 0) Gradle DSL method not found: 'google()'
Switching google() to maven { url 'https://maven.google.com' } does not fix the issue.
I have other projects that build just fine with this CI provider, using what appear to be the same configurations. The project with the issue is being built by the CI server in a fresh virtual machine, from the repository source, so I would not expect any cached state issues to cause this. It is intriguing that it builds ok locally every time, just not on the CI server.
The cause of this was that in the "app" module of the project (one level below the project root) there was a second copy of gradle and the gradle wrapper, and the gradle wrapper was configured to an old v2.2.
Locally this is not a problem, but for whatever reason Nevercode CI uses that Gradle v2.2 from the app module for builds, and then fails as the version is way too old.
If you see this scenario, check your sub-modules for stray copies of older versions of Gradle...

install repository and sync project. android studio

When opening Android Studio I get the following error messages under messages Gradle Sync:
Please help. I need it for my work.
Add this to your project level build.gradle:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
as described here: cannot install repository and sync project - not able to use support libraries 25.2.0

Categories

Resources