Qt Android output apk generated in ~/android-build\build\outputs\apk\debug - android

Problem: I want to use Android build system (gradle version 3) with Qt project, but this version of gradle (compared to old version 2) would change location of generated output apk file to be under $buildDir/outputs/apk/debug instead of $buildDir/outputs/apk (added debug folder), but when Qt Android kit tries to install app to Android device it only looks in old location, and fails to locate the apk file. I checked with Android Studio and its same which indicates gradle 3 is working normal
old location: $build_folder/android-build\build\outputs\apk\my.apk
New location: $build_folder/android-build\build\outputs\apk\debug\my.apk
Error (Compile):
adb: error: cannot stat
'D:/Qt/FireBase/build-client01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_0_for_Android_armv73-Release/android-build//build/outputs/apk/android-build-debug.apk':
No such file or directory
This problem occurs only when I make changes to default build.gradle generated by Qt to set gradle to version 3, the default generated file have classpath set to old version 2.3.3,
old: classpath 'com.android.tools.build:gradle:2.3.3'
new : classpath 'com.android.tools.build:gradle:3.1.0
There are other changes I made, that also require change in gradle-wrapper.properties, here are updated files:
build.gradle
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
//classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
jcenter()
//google() // Google's Maven repository
maven {
url "https://maven.google.com"
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
dependencies {
// ...
//libfirebase_auth.a
//libfirebase_app.a
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.android.gms:play-services-base:15.0.1'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
apply plugin: 'com.google.gms.google-services'
gradle-wrapper.properties
#Mon Feb 20 10:43:22 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

I use this on my build.gradle :
android {
...
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "../" + outputFileName
}
}
}

I still don't know where and how to instruct Qt to look into new output structure, but as a workaround for now , I added configuration to build.gradle to make a copy of the generated apk back to ~/apk where Qt looks for!
// make a copy of APK from "$buildDir/outputs/apk/debug" back to "$buildDir/outputs/apk"
def archiveBuildTypes = ["release", "debug"];
applicationVariants.all { variant ->
variant.outputs.all { output ->
if (variant.buildType.name in archiveBuildTypes) {
def taskSuffix = variant.name.capitalize()
def assembleTaskName = "assemble${taskSuffix}"
if (tasks.findByName(assembleTaskName)) {
def copyAPKFolderTask = tasks.create(name: "archive${taskSuffix}", type: org.gradle.api.tasks.Copy) {
description "copy APK to old folder"
def sourceFolder = "$buildDir/outputs/apk/$output.baseName"
def destinationFolder = "$buildDir/outputs/apk"
print "Copy apk from: $sourceFolder into $destinationFolder\n"
from(sourceFolder)
into destinationFolder
eachFile { file ->
file.path = file.name // so we have a "flat" copy
}
includeEmptyDirs = false
}
tasks[assembleTaskName].finalizedBy = [copyAPKFolderTask]
}
}
}
}
Update:
gradle 3.1.x and higher require at least androidBuildToolsVersion 27, while Qt currently supports no higher than androidBuildToolsVersion 26, So practically may be its safer to fall back to gradle 3.0.x which supports build tools 26
It's also even possible to fall back to gradle 2.3.3 (use compile instead of implementation for FireBase and any required modules:
compile 'com.google.firebase:firebase-core:16.0.1'
...

Related

Build error when trying to add Firebase dependency to Qt project

I would like to use Firebase the same way as in any native Android app non using Qt (i.e. using Java). I'm already have one (all is working fine).
Now I'm trying to add Firebase to my existing Qt project. For now, I'm trying to add all the required dependencies to build.gradle (so I can use Firebase APIs in my Java source code part of my Qt project), and getting weird errors.
I'm not good in Gradle so any help is appreciated (if this is possible at all, because I'm using quite old Qt 5.12.12).
This is build.gradle I have (builds and runs fine):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.jakewharton:process-phoenix:2.1.2' // https://github.com/JakeWharton/ProcessPhoenix
implementation 'me.dm7.barcodescanner:zxing:1.9.13' // https://github.com/dm77/barcodescanner
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
// Buggy thing: fails to build. Needs to be replaced with actual numbers.
// https://stackoverflow.com/a/46290586/3765267
/*compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion*/
compileSdkVersion 30
buildToolsVersion "30.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
This is build.gradle with all the dependencies I try to add (I've added classpath 'com.google.gms:google-services:4.3.14' to dependencies section and apply plugin: 'com.google.gms.google-services' line):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.3.14'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.jakewharton:process-phoenix:2.1.2' // https://github.com/JakeWharton/ProcessPhoenix
implementation 'me.dm7.barcodescanner:zxing:1.9.13' // https://github.com/dm77/barcodescanner
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
// Buggy thing: fails to build. Needs to be replaced with actual numbers.
// https://stackoverflow.com/a/46290586/3765267
/*compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion*/
compileSdkVersion 30
buildToolsVersion "30.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
And now I'm getting the following weird error trying to build the project:
Generating Android Package
Input file: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-libfdm.so-deployment-settings.json
Output directory: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-build/
Application binary: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/bin/libfdm.so
Android build platform: android-33
Install to device: No
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Work\Source\build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug\ui\android-build\build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'android-build'.
> ASCII
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
Addition #1. I can build using Qt 6.4.1 + Firebase. The question is about Qt 5.12.12. I suspect the reason is too old Gradle version it's using (4.6) or something like that.
By default in android we declare the plugin dependencies in gradle root module. Seems like in qt project we have only one flat layer with only one build.gradle file. The good news is that we can declare plugin dependencies in settings.gradle as well
Make sure you connected the plugin in settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.google.gms.google-services' version '4.3.10' apply false
}
}
now you can apply the plugins in build.gradle like this:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android { ... }

Gradle error in Android Studio: Could not find “com.android.tools.build:gradle:7.1.1.”

I am trying to import a project from Eclipse into Android Studio.
In Eclipse I exported it to gradle and then imported it into Android Studio.
Note: I am new to gradle and have no insight to problem.
Now I get this error:
> Configure project :
Running gradle version: 6.8
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'aBooks'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.1.1.
Searched in the following locations:
-
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.1/gradle-7.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
The link given leads to a “404 Page not found”.
The gradle files on my system with “gradle-7” are:
The gradle file :
buildscript {
// added crl https://tomgregory.com/anatomy-of-a-gradle-build-script/
repositories {
mavenCentral()
}
println "Running gradle version: $gradle.gradleVersion"
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1' // **original error here**
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
// implementation group: 'com.android.tools.build', name: 'gradle', version: '7.1.0-alpha01'
// https://mvnrepository.com/artifact/com.android.tools.build/gradle/7.1.0-alpha01
}
}
apply plugin: 'com.android.application' // 'android'
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation project(':CRLibs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
android {
compileSdk 26
buildToolsVersion "32.0.0"
buildFeatures {
prefab true
prefabPublishing true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml,
...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
// no joy
plugins { // added crl https://developer.android.com/studio/releases/gradle-plugin#groovy
id 'com.android.application' version '7.0.0-alpha13' apply false
id 'com.android.library' version '7.0.0-alpha13' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
}
I tried changing ‘7.1.1’ to ‘7.2’ no change. I have no clue on how to fix this. All the answers given in my searches do not match the versions here or were no help.
EDIT1:
Added info. when I go to file->Project Structure & Project, I see
Note that the Gradle version is blank. If I enter 6.8 or 7.1.1 and click OK, I get the same results and then if I go back the Gradle version is blank.
Gradle version 6.8 is identified at the current version(see line 2 of the error message. Don't know if this means anything.
This is the list of my Gradel-6* files:
Add google() to your repositories { } block. The Android Gradle plugin is located there.
Have the same problem
this was my solution
classpath 'com.android.tools.build:gradle:7.2.0'

Unable to merge dex error in Android Studio 3.0.1 after adding google cloud storage dependency

I am attempting to send data to a google cloud storage bucket in an android app so am trying to import the com.google.cloud:google-cloud-storage:1.22.0 library. However this leads to the error
Error:Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have tried multiple answers from this SO question which had the same error. Tried fixes include:
Adding multiDexEnabled true to the defaultConfig and including android.support:multidex in the dependencies
Adding transitive=true to the import [implementation('com.google.cloud:google-cloud-storage:1.22.0'){transitive = true}]
Attempted to inspect the transitive dependencies using ./gradlew dependencies but recieved the error Could not find com.android.tools.build:gradle:3.0.1
The build.gradle I am using orginally comes from the tensorflow example app.
project.buildDir = 'gradleBuild'
getProject().setBuildDir('gradleBuild')
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'org.apache.httpcomponents:httpclient:4.5.4'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
// set to 'bazel', 'cmake', 'makefile', 'none'
def nativeBuildSystem = 'none'
// Controls output directory in APK and CPU type for Bazel builds.
// NOTE: Does not affect the Makefile build target API (yet), which currently
// assumes armeabi-v7a. If building with make, changing this will require
// editing the Makefile as well.
// The CMake build has only been tested with armeabi-v7a; others may not work.
def cpuType = 'armeabi-v7a'
// Output directory in the local directory for packaging into the APK.
def nativeOutDir = 'libs/' + cpuType
// Default to building with Bazel and override with make if requested.
def nativeBuildRule = 'buildNativeBazel'
def demoLibPath = '../../../bazel-bin/tensorflow/examples/android/libtensorflow_demo.so'
def inferenceLibPath = '../../../bazel-bin/tensorflow/contrib/android/libtensorflow_inference.so'
// If building with Bazel, this is the location of the bazel binary.
// NOTE: Bazel does not yet support building for Android on Windows,
// so in this case the Makefile build must be used as described above.
def bazelLocation = '/usr/local/bin/bazel'
// import DownloadModels task
project.ext.ASSET_DIR = projectDir.toString() + '/assets'
project.ext.TMP_DIR = project.buildDir.toString() + '/downloads'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
lintOptions {
abortOnError false
}
sourceSets {
main {
// Android demo app sources.
java {
srcDir 'src'
}
manifest.srcFile 'AndroidManifest.xml'
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = [project.ext.ASSET_DIR]
jniLibs.srcDirs = ['libs']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
task buildNativeBazel(type: Exec) {
workingDir '../../..'
commandLine bazelLocation, 'build', '-c', 'opt', 'tensorflow/examples/android:tensorflow_native_libs', '--crosstool_top=//external:android/crosstool', '--cpu=' + cpuType, '--host_crosstool_top=#bazel_tools//tools/cpp:toolchain'
}
task buildNativeMake(type: Exec) {
environment "NDK_ROOT", android.ndkDirectory
// Tip: install ccache and uncomment the following to speed up
// builds significantly.
// environment "CC_PREFIX", 'ccache'
workingDir '../../..'
commandLine 'tensorflow/contrib/makefile/build_all_android.sh', '-s', 'tensorflow/contrib/makefile/sub_makefiles/android/Makefile.in', \
'-t', 'libtensorflow_inference.so libtensorflow_demo.so all' \
, '-a', cpuType //, '-T' // Uncomment to skip protobuf and speed up subsequent builds.
}
task copyNativeLibs(type: Copy) {
from demoLibPath
from inferenceLibPath
into nativeOutDir
duplicatesStrategy = 'include'
dependsOn nativeBuildRule
fileMode 0644
}
tasks.whenTaskAdded { task ->
}
// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
//apply from: "download-models.gradle"
//
// compile 'com.google.apis:google-api-services-appengine:v1-rev52-1.23.0' exclude module: 'httpclient'
dependencies {
if (nativeBuildSystem == 'cmake' || nativeBuildSystem == 'none') {
compile 'org.tensorflow:tensorflow-android:+'
}
implementation 'com.google.code.gson:gson:2.8.2'
compileOnly 'com.google.auto.value:auto-value:1.5.1'
annotationProcessor 'com.google.auto.value:auto-value:1.5.1'
implementation 'com.google.cloud:google-cloud-storage:1.22.0' exclude module: 'httpclient'
implementation 'com.google.apis:google-api-services-tasks:v1-rev48-1.23.0' exclude module: 'httpclient'
implementation 'com.google.apis:google-api-services-discovery:v1-rev62-1.23.0' exclude module: 'httpclient'
implementation 'com.google.protobuf:protobuf-java:3.5.1'
implementation 'com.android.support:multidex:1.0.2'
implementation files('libs/TarsosDSP-Android-2.4.jar')
}
Would anyone know what is causing this error or even how I can find out why I am getting it? (It may be that I need to get ./gradlew dependencies to run, I'm not discarding that I just left it for now to avoid going down too many debugging rabbit holes).
See the friendly blue note which I ignored on the Cloud Storage API docs
(screenshot taken 21/03/18)

Android Gradle library dependency with library dependency using Nexus

I'm switching my project over to using Gradle and an internal SonaType Nexus for hosting my dependencies. My core project depends on library project A and library project A has a dependency on library project B.
My issue is that as soon as I add LibA to my main project I get this error:
"Module version com.example:LibA:1.1 depends on libraries but is not a library itself"
I have no issues adding library projects with jar dependencies with the same build script. I have seen people doing this successfully with LOCAL (in the project) android libraries but no one doing it with maven repos.
Is this a bug in gradle or did I misconfigure the library builds?
Core Project Build
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
maven {
url "http://localhost:8081/nexus/content/repositories/releases/"
}
maven {
url "http://localhost:8081/nexus/content/repositories/central/"
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile('com.example:LibA:1.+')
}
LibA Build
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
versionCode = "3"
versionName = "1.2"
}
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aild.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile ('com.example:LibB:1.+')
} ...
LibB Build
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
versionCode = "1"
versionName = "1.0"
}
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aild.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
repositories {
mavenCentral()
}
dependencies {
} ...
Edit: Adding -info output for the error.
* What went wrong:
A problem occurred configuring project ':GradleTest'.
> Failed to notify project evaluation listener.
> Module version com.example:LibA:1.+ depends on libraries but is not a library itself
Edit 2: Adding my local maven upload script for LibA
apply plugin: 'maven'
apply plugin: 'signing'
group = "com.example"
version = defaultConfig.versionName
configurations {
archives {
extendsFrom configurations.default
}
}
signing {
required { has("release") && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
configuration = configurations.archives
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: sonatypeRepo) {
authentication(userName: sonatypeUsername,
password: sonatypePassword)
}
pom.project {
name 'com-example'
packaging 'aar'
description 'none'
url 'https://internal github link'
scm {
url 'scm:git#https://internal github link'
connection 'git#https://internal github link'
developerConnection 'git#https://internal github link'
}
licenses {
license {
name 'example'
url 'example'
distribution 'example'
}
}
developers {
developer {
id 'example'
name 'example'
email 'example'
}
}
groupId "com.example"
artifactId rootProject.name //LibA
version defaultConfig.versionName
}
}
}
Your line in the dependencies to include LibA is wrong. To include a library project, use this:
compile project(':LibA')
If the library's directory isn't at the root of your project directory, you'll need to specify a colon-delimited path. For example, if your directory structure is:
projectFolder
|
+--coreProject
|
+--libraries
|
+--LibA
|
+--LibB
your dependency will be:
compile project(':libraries:LibA')
This is the same as the notation you use in your settings.gradle file.
Maybe problem is that you use mavenCentral as your repository for library projects
repositories {
mavenCentral()
}
and not yours nexus repository where actual dependencies exists
repositories {
maven {
url "http://localhost:8081/nexus/content/repositories/releases/"
}
maven {
url "http://localhost:8081/nexus/content/repositories/central/"
}
}
If you uploaded library artifact for both jar and aar, try this.
compile 'com.example:LibA:1.1.1#aar'
In my work, I have used compile project(':google-play-services_lib') instead of compile ('google-play-services_lib') when I declare dependent projects in my build.gradle file. I think that is the right way to do this with Gradle: http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:project_dependencies
if you don't want to have it as sub-module in the first build.gradle file you can add your local maven repository
mavenLocal()
//repositories
repositories {
mavenCentral()
mavenLocal()
}
but you need to run install on libA first.
I had a similar error message after introducing by mistake a cyclic dependency between libraries:
build.gradle in commons-utils
dependencies {
...
instrumentTestCompile project(':test-utils')
}
build.gradle in test-utils
dependencies {
...
compile project(':commons-utils')
}
Fixing this solved the problem. The error message is not very explicit.
Don't know for sure, just a couple of thoughts:
Have you tried running gradle assemble instead gradle build? This should skip tests, as I see error is related to test task.
Maybe stupid, but try to remove dependcy on 2nd lib from the first and put it to your main build file listing before the first. I have a memory of something related. This way the second lib may be added to classpath allowing the first to compile.
Try to create .aar files by hand and upload it to repo also by hand.
It's a hack, but maybe it'll work: have you considered to exclude this :GradleTest module? See section 50.4.7
This issue has gone away with the later versions of Gradle and the Android Gradle Plugin. Seems to have just been an early release bug.

Android Studio: Gradle build fails -- Execution failed for task ':compileDebugAidl'

After changes to source and building with gradle in Android Studio (I/O preview) AI - 130.677228 the build fails with the following error:
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugAidl'.
> No signature of method: com.android.ide.common.internal.WaitableExecutor.waitForTasks() is applicable for argument types: () values: []
Possible solutions: waitForAllTasks()
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
The second time running a build the build will succeed.
Using a gradle wrapper with version 1.6
This really sucks because it does a long build (non-incremental) after it fails the first time.
Is there a way to not have this failure?
EDIT to include build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
task wrapper(type: Wrapper) {
gradleVersion = '1.6'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion "Google Inc.:Google APIs:17"
buildToolsVersion "17"
defaultConfig {
minSdkVersion 11
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
Link to issue on Google Code: https://code.google.com/p/android/issues/detail?id=56158
I solved this issue by setting buildToolsVersion in my build.gradle file to match the latest version of the Android SDK Build-tools in the SDK manager.
In my case, I have the Android SDK Build-tools version 22.0.1 installed, so I set buildToolsVersion accordingly:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
...
After making that change, my app builds uneventfully.
I'm not sure how this is possible. It looks like you have a mismatch between the Gradle plugin itself and its dependencies that provides the WaitableExecutor class.
However you mention Gradle 1.5 and this is a problem.
The plugin version 0.3 was compatible with Gradle 1.3-1.4
The new version release last week, 0.4 is compatible with Gradle 1.6+
Make sure you use 0.4 and the new Gradle version.
I was facing the same issue "Failed to execute the task: compileDebugaidl aidl/debug/".
I saw further in Gradle Console for the specifics and it read as below:
Failed to capture snapshot of output files for task 'prepareComAndroidSupportAppcompatV72103Library' during up-to-date check.
Could not remove entry '/Users/..../.../.../..../build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3' from cache outputFileStates.bin (/Users/..../..../..../.gradle/2.2.1/taskArtifacts/outputFileStates.bin).
I resolved it by deleting the outputFileStates.bin file from the terminal and allowed Gradle to recreate it.
Hope it helps somebody.
Add:
compileSdkVersion 17 to your buid.gradel file (below).
And use version 3 of the plugin: com.android.tools.build:gradle:0.3 (or higher for future questions,etc)
Edit: reference project I just created. Builds, signs,etc https://github.com/yegdroid/gradle_demo
//
// A basic Android application that follows all the conventions
//
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.3'
}
}
apply plugin: 'android'
android {
testBuildType = "debug"
defaultConfig {
versionCode = 1
versionName = "0.1"
minSdkVersion = 9
targetSdkVersion = 17
compileSdkVersion 17
buildConfig "private final static boolean DEFAULT = true;", \
"private final static String FOO = \"foo\";"
}
buildTypes {
debug {
packageNameSuffix = ".debug"
buildConfig "private final static boolean DEBUG2 = false;"
}
}
aaptOptions {
noCompress "txt"
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
}
res {
srcDir 'res'
}
assets {
srcDir 'assets'
}
resources {
srcDir 'src'
}
}
}
}
Add the code below into your build.gradle file. This works for me.
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
Please, try checking "Use default gradle wrapper" option in the Project-level settings.
Android Studio --> File --> Settings --> Build, Execution, Deployment --> Build Tools --> Gradle
Like to register my problem and solution here since it is almost relevent to the issue posted that if someone stumbles across the error could overcome it quickly.
I faced a similar issue with Failed to execute the task: compileDebugaidl aidl/debug/.. Access is denied ...
I overcame the issue by deleting the build directory and rebuilding it again[I'm using the Gradle 0.14.4]
This works for me
edit in your project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
//delete this line below
classpath 'com.android.tools.build:gradle:1.0.1'
//add this line below
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
The missing AIDL something is google android studio problem to not update major gradle dependencies class path.
Fix:
- open project gradle file (no app, project !)
- replace:
classpath 'com.android.tools.build:gradle:1.0.1' or whatever
with
classpath 'com.android.tools.build:gradle:1.3.1'
If you can not compile a time before, compilable project, the google cat & dog are not sleeping and theire making changes, updates, therefore you have to wake up and made changes where they forget to.
And gradle is quite unstable project and buggy.
Can i see gradle (error filtered) output? (toolwindow gradle, gradle tab)
Looks like there is problem with functions inside the aidl files, which are mostly for outside application interface, & services.
Etc to transfer data to widget, or if you need data transfer between two applications.
Second posibility is two libraries with the same aidl structure, just one function is differrent, than one, or you are using the same library twice.
Another reason i newer saw with this message

Categories

Resources