Why does my android app build locally but fails with Github Actions? - android

I have a project that compiles fine when I run ANDROID_HOME=/.../Library/Android/sdk gradle clean assembleDebug. But when I try to run the same on a github action like this...
on:
push:
branches:
- '**'
jobs:
test:
name: Analyze Android
runs-on: ubuntu-latest
steps:
- name: Checkout App
uses: actions/checkout#v2
- uses: actions/setup-java#v3
with:
distribution: temurin
java-version: 11
- name: Setup Gradle
uses: gradle/gradle-build-action#v2
- name: Setup Android SDK
uses: android-actions/setup-android#v2
- name: Assemble
run: |
./gradlew clean assembleDebug
I get
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :DTO.
Required by:
project :app
project :app > project :UI
project :app > project :Data
project :app > project :Domain
> No matching configuration of project :DTO was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.2.1', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- None of the consumable configurations have attributes.
But the DTO project does exist and as I said works locally. I checked the versions and they look to be the same...
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
Build time: 2022-08-05 21:17:56 UTC
Revision: d1daa0cbf1a0103000b71484e1dbfe096e095918
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 15.0.2 (Oracle Corporation 15.0.2+7-27)
OS: Mac OS X 10.16 x86_64
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
Build time: 2022-08-05 21:17:56 UTC
Revision: d1daa0cbf1a0103000b71484e1dbfe096e095918
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.16 (Eclipse Adoptium 11.0.16+8)
OS: Linux 5.15.0-1014-azure amd64
Why does it work locally but not via Github Actions?
Updates
It looks like it is because the library is setup like this...
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm'
}
instead of like the rest...
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
So it finds the others but not this one. But I tried converting to an android app and I get the same issue.

In my case it was because my local box was OSX (not case sensitive) and the build box was Ubuntu (case sensitive). Once the name was lowercased it worked.

I think your computer doesn't have enough space(RAM) for Build. I also faced the similar issue but it got resolved when I Increased my internal ram.

Related

Bitbucket CI/CD : Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

I am using Bitbucket CI/CD Pipelines to make a Release build of my Android Application.
Here I am facing an issue while creating Android Release build.
It says
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
And I have tried the same but looks like CI/CD has nothing to do with System and IDE.
Then How should I make gradle work with JAVA 11?
Below is my yml file
image: androidsdk/android-30
pipelines:
default:
- parallel:
- step:
name: Lint
caches:
- gradle
script:
- ./gradlew lint
artifacts:
- app/build/reports/**
- step:
name: Build Release
image: bitbucketpipelines/android-ci-image
caches:
- gradle
script:
- echo $KEYSTORE_FILE_BASE64 | base64 --decode > $KEYSTORE_FILE
- ./gradlew assembleRelease
artifacts:
- app/build/outputs/**
Some of the Answer on here says need to add
image: openjdk:11-jdk
But where should i add that it already have android-30 image to make andorid build

Gradle Android rootProject.configurations vs configurations

My task is defined inside app/build.gradle
rootProject.configurations has no configuration while configurations has everything e.g. "implementation", "testImplementation" etc.
Why?
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------
Build time: 2019-04-26 08:14:42 UTC
Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Mac OS X 10.14.6 x86_64
The build.gradle file in the app folder defines a sub module (or sub project). The build.gradle file in the root folder defines the root project.
The configurations are added by plugins and in most use cases there is no need to apply a plugin in the root project.

Cannot use android studio on Mac due to gradle

Error:Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Tried everything, Android Studio still does not works. Re-installed 10 times, cleaned all .gradle .android folder. Created example project from scratch. Tried changing the gradle version. Nothing almost nothing works.
There is no system gradle, my Java version is javac 1.8.0_40
Contents of gradle config
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here are the contents of idea.log
2015-11-08 22:40:39,654 [ 471024] WARN - nal.AbstractExternalSystemTask - Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:438)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:348)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:164)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:366)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:332)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:225)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:97)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:65)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4.execute(ExternalSystemUtil.java:540)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5$2.run(ExternalSystemUtil.java:621)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
2015-11-08 22:40:39,655 [ 471025] WARN - radle.project.ProjectSetUpTask -
2015-11-08 22:40:39,655 [ 471025] INFO - radle.project.ProjectSetUpTask - Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Consult IDE log for more details (Help | Show Log)
2015-11-08 22:40:39,655 [ 471025] INFO - ls.idea.gradle.GradleSyncState - Sync with Gradle for project 'My Application' failed: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Based on suggestions I installed gradle seperately, I had to fix this error https://issues.gradle.org/browse/GRADLE-1451 but I now have ANDROID_HOME, gradle defined and gradle --version works.
------------------------------------------------------------
Gradle 2.7
------------------------------------------------------------
Build time: 2015-09-14 07:26:16 UTC
Build number: none
Revision: c41505168da69fb0650f4e31c9e01b50ffc97893
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_40 (Oracle Corporation 25.40-b25)
OS: Mac OS X 10.9.5 x86_64
**Yet I am still getting the same error from Android Studio. Also in a bizarre manner it simply refuses to accept the gradle home folder, always showing error that Gradle home folder is incorrect, even when I used lib or bin sub directory the error still remains. And it automatically switches back to the wrapper. **
Error:Could not create an instance of Tooling API implementation using the specified Gradle installation '/Users/aub3/gradle'.
When built from command like using 'gradle build' I get following error
:app:compileReleaseSources
:app:preDexRelease
:app:dexRelease
:app:packageRelease
:app:assembleRelease
:app:assemble
:app:compileLint
:app:lint
Ran lint on variant debug: 4 issues found
Ran lint on variant release: 4 issues found
Wrote HTML report to file:/Users/aub3/IdeaProjects/Dsdsadasd/app/build/outputs/lint-results.html
Wrote XML report to /Users/aub3/IdeaProjects/Dsdsadasd/app/build/outputs/lint-results.xml
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestJavaWithJavac
:app:compileDebugUnitTestSources
:app:mockableAndroidJar
:app:assembleDebugUnitTest
:app:testDebugUnitTest
java.lang.ClassCastException: ch.qos.logback.classic.LoggerContext cannot be cast to org.gradle.logging.internal.slf4j.OutputEventListenerBackedLoggerContext
at org.gradle.logging.internal.slf4j.Slf4jLoggingConfigurer.configure(Slf4jLoggingConfigurer.java:42)
at org.gradle.logging.internal.DefaultLoggingConfigurer.configure(DefaultLoggingConfigurer.java:34)
at org.gradle.logging.internal.LoggingSystemAdapter.setLevel(LoggingSystemAdapter.java:55)
at org.gradle.logging.internal.LoggingSystemAdapter.on(LoggingSystemAdapter.java:42)
at org.gradle.logging.internal.DefaultLoggingManager$StartableLoggingSystem.start(DefaultLoggingManager.java:191)
at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:60)
at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:31)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:58)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:41)
at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:49)
at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:33)
at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:69)
at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:74)
:app:testDebugUnitTest FAILED
FAILURE: Build failed with an exception.
I finally got gradle to assemble android project and install on a devide via gradle installDebug task using command line. Android Studio however still does NOT works.
Error:Could not create an instance of Tooling API implementation using the specified Gradle installation '/Users/aub3/gradle'.
Solved
I could get gradle wrapper to work with following
DEFAULT_JVM_OPTS="-Djava.ext.dirs="
However there is no way to use this setting with Android Studio.
Also unlike what I read online , there are multiple directories
[java.ext.dirs] = /Users/aub3/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java.
I went to each directory and removed Jar files for Loggers, sl4j and others. With this I was able to get Android Studio to work.
Check for conflicts in /Library/Java/Extensions.
In my case, I had logback-classic.jar, logback-core.jar, slf4j-api.jar and xuggle-xuggler.jar all soft-linked from some directory /usr/local/xuggler/share/java/jars/ (which I don't recall what may have installed it).
I just put these files (or links) away and now I'm able to use Gradle both from the command line and from within Android Studio. (I created a script to restore the soft-links in case my setup is broken somewhere else, but so far, I haven't run into any problems).
You can Download GRADLE on website. Gradle Download.
Save on any directory (example: /Users/ihojose/Documents/gradle).
Open Console and add system variable.
vi ~/.profile
Copy and paste the following text into the .profile file:
GRADLE_HOME=/Users/ihojose/Documents/gradle;
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin
Test gradle in console
gradle -version
If result if similar to this:
------------------------------------------------------------
Gradle 1.0-rc-3
------------------------------------------------------------
Gradle build time: Monday, Novenber 9, 2015 16:10:52 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 2.6.0 compiled on October 21 2015
Ivy: 2.2.0
JVM: 1.8.0_68 (Apple Inc. 20.6-b01-415)
OS: Mac OS X 11.0.1 x64
Define ANDROID_HOME
Click here for How to define ANDROID_HOME
Now you can use Android Studio.

Invalid tool ID 2.2 on jenkins gradle automatic install how to resolve?

I am trying to setup jenkins for android gradle build. So in manage jenkins --> configure system --> gradle --> gradle installations I set these values
gradle <-- name
Yes <-- install automatically
2.2 <-- version
in my jenkins build project:
build --> invoke gradle script --> gradle version: "gradle", tasks: "clean build"
When I run my build it fails with message:
Checking out Revision 7c2d53cc5df5a48695b0828f18de0573d072dd60 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 7c2d53cc5df5a48695b0828f18de0573d072dd60
> git rev-list 7c2d53cc5df5a48695b0828f18de0573d072dd60 # timeout=10
[Gradle] - Launching build.
Invalid tool ID 2.2
[Gradle] - [ERROR] Can't retrieve the Gradle executable.
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
Am I doing wrong? is this a bug? how can I fix this to work please?
I just had the same problem. The list of Gradle versions was not being shown.
The file JENKINS_HOME/updates/hudson.plugins.gradle.GradleInstaller should contain the list of installations. For some reason it was not populated.
In order to populate/update this file go to:
Manage Jenkins -> Manage Plugins -> Advanced: Click "Check Now" button at the bottom/right of the page.
Source: https://issues.jenkins-ci.org/browse/JENKINS-27310

Gradle wrapper version in sub-module is different than in project root

I am new in Android studio & Gradle.
My project structure is like this:
MyProject
-LibModuleOne
-...
-build.gradle
-LibModuleTwo
- ...
-buld.gradle
-AppModule
-...
-build.gradle
buld.gradle
On command line, under MyProject/ , ./gradlew --version shows me that I am using gradle 2.1:
./gradlew --version
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
Build time: 2014-09-08 10:40:39 UTC
Build number: none
Revision: e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_25 (Oracle Corporation 25.25-b02)
OS: Mac OS X 10.8.5 x86_64
But, if I check the version under MyProject/LibModuleOne/ or MyProject/LibModuleTwo/ or MyProject/AppModule/ they all show me that I am using gradle 1.12:
./gradlew --version
------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------
Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.8.0_25 (Oracle Corporation 25.25-b02)
OS: Mac OS X 10.8.5 x86_64
The build.gradle of project root declares using Android plugin version0.13.3 :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
}
}
In Android studio, File-->Project structure --> shows Gradle 2.1
Why gradle wrapper shows different version in sub-modules than project root ? How to make all my sub-modules use Gradle 2.1 ?
You appear to have multiple wrappers installed (otherwise ./gradlew wouldn't work from subdirectories). You need to remove all gradlew scripts and gradle/wrapper directories except for the ones in the root project's directory.

Categories

Resources