I am working on one library project in android. I want to upload my library to the JCenter. I have created bintray account etc & followed all steps which are mentioned here http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
I did below changes in my application module & library module.
Application Module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.testapp"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':testlib')
}
Library Module build.gradle
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'test-sdk'
publishedGroupId = 'in.test.sdk'
libraryName = 'testlib'
artifact = 'test-sdk'
libraryDescription = 'A wrapper for Facebook Native Like Button (LikeView) on Android'
siteUrl = 'https://github.com/xyz/testsdk'
gitUrl = 'https://github.com/xyz/testsdk.git'
libraryVersion = '1.0.0'
developerId = 'xyz'
developerName = 'xyz'
developerEmail = 'xyz#xyz.xyz'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
version = "1.0.0"
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles 'proguard-project.txt'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile files('libs/gson-2.3.1.jar')
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/jackson-annotations-2.5.0.jar')
compile files('libs/javax.annotation.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/okhttp-2.3.0.jar')
compile files('libs/okio-1.3.0.jar')
compile files('libs/retrofit-1.9.0.jar')
}
Project root build.gradle
// 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.1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
When I am doing this gradlew install then I am getting this error
FAILURE: Build failed with an exception.
* What went wrong:
Task 'install' is ambiguous in root project 'TestApp'. Candidates are: 'installDebug', 'installDebugAndroidTest'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.685 secs
I spent three days on same but could not get proper solution of it. Please suggest how to resolve it.
Perhaps you forgot to add these lines to the end of your Library Module build.gradle:
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
You are telling gradle to do the 'install' task but it is telling you that there is no 'install' task and gives suggestions of close task matches like 'installDebug'.
Basically your plugins do not include an install task. If you want to see all the tasks that are available to you run the command below
gradlew tasks --all
Related
I have a capacitor app and I'm trying to implement the Firebase Distribution with Gradle (https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab) but I'm stuck at this error:
No signature of method: build_clqfykx9rkn9m9ygw4eh6w1bu.android() is applicable for argument types: (build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1) values: [build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1#60526ded]
I've did all the steps of the process and my build.gradle files look like this:
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.5'
// Add the App Distribution Gradle plugin
classpath 'com.google.firebase:firebase-appdistribution-gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle:
apply plugin: 'com.android.application'
// Apply the App Distribution Gradle plugin
apply plugin: 'com.google.firebase.appdistribution'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.some.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName project.hasProperty('version') ? version : '1.0.0'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
flavorDimensions "environment"
productFlavors {
appA {
dimension "environment"
manifestPlaceholders = [displayName:"App A"]
}
appB {
dimension "environment"
applicationIdSuffix ".amigdala"
manifestPlaceholders = [displayName:"App B"]
}
}
signingConfigs {
release {
storeFile file("app-keystore.jks")
storePassword System.getenv("KSTOREPWD")
keyAlias "mykey"
keyPassword System.getenv("KEYPWD")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
// https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
firebaseAppDistribution {
serviceCredentialsFile "./service-account-key-distribution.json"
artifactType "AAB"
archivePath System.getenv("ARCHIVE_PATH")
releaseNotes "Change this before releasing in production!"
}
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
of course, everything worked until I added this part:
// https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
firebaseAppDistribution {
serviceCredentialsFile "./service-account-key-distribution.json"
artifactType "AAB"
archivePath System.getenv("ARCHIVE_PATH")
releaseNotes "Change this before releasing in production!"
}
I'm very new at modifying build.gradle files so I guess is sometihng syntax related but I can't figure it out. Even if I make small changes like artifactType "AAB" -> artifactType="AAB" I keep bouncing from this error to this one: Task 'appDistributionUploadRelease' not found in root project 'android'.
Any help or leads will be apreciated, thank you.
No signature for method : build.android... Seams to appear when there's something wrong with you Gradle configuration, like missing properties in the firebaseAppDistribution property or wrong file paths. Once I fixed that i had the Task 'appDistributionUploadRelease' not found in root project 'android' problem, which I solved (by pure luck) changing the appDistributionUploadRelease command for appDistributionUploadAppARelease. It seems the task doesn't have a generic command and the flavour must be specified.
When I commit and push changes to gitlab,assembly falls with an error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':somebible-id-client-app'.
> Could not resolve all dependencies for configuration ': somebible-id-client-app:_secondaryDebugApkCopy'.
> Could not resolve ru.somebible.android:statistic:0.0.5.
Required by:
project :somebible-id-client-app
> Skipped due to earlier error
* 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 1m 22s
ERROR: Job failed: exit code 1
My build.gradle:
buildscript {
repositories {
mavenCentral()
maven {
url 'http://jenkins01.mobile.somebible.ru:7700/nexus/content/repositories/somebible-internal/'
}
google()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
repositories {
mavenCentral()
maven {
url 'http://jenkins01.mobile.somebible.ru:7700/nexus/content/repositories/somebible-internal/'
}
google()
jcenter()
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "ru.somebible.somebibleidclientapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
useProguard false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prod {
resValue "string", "app_name", "Id Client App"
}
secondary {
applicationId "ru.somebible.somebibleidclientappsecondary"
resValue "string", "app_name", "Id Client Secondary App"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
dependencies {
ext.support_version = '25.3.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':somebible-id')
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile "com.android.support:appcompat-v7:$ext.support_version"
compile "com.android.support:design:$ext.support_version"
compile 'com.jakewharton:butterknife:8.0.1'
compile 'io.reactivex:rxjava:1.1.3'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.hannesdorfmann.mosby:mvp:2.0.1'
compile 'com.annimon:stream:1.1.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'ru.somebible.android:statistic:0.0.5'
testCompile 'junit:junit:4.12'
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
And most importantly, there is no such process, even without the prefix ApkCopy. That is, to see what the problem is locally impossible, since locally there is no such process and locally everything works. Direct please in the right direction.
Thank you for answers!
Gradle is trying to download the artifact ru.somebible.android:statistic but fails to do so because it can't find it in any known artifact repository. I assume that the artifact is published in this repository: 'http://jenkins01.mobile.somebible.ru:7700/nexus/content/repositories/somebible-internal/'
In that case, make sure that your build machine has access to this repository and make sure that that artifact can actually be found in that repository.
I have successfully uploaded the android library through android studio terminal on Bintray and library is also added to JCenter. Now, I used gradle dependency code snippet in gradle file. it has sync successfully for version "1.0.0".
Next, I updated the library version from 1.0.0 to 1.0.1 and upload that library to Bintray. It's successfully uploaded. also, I used gradle dependency code snippet in gradle file. its also completed sync successfully for version 1.0.1 as well.
But I could not access the library class and function. because the class or java file does not exist in classes.jar folder of the external libraries of the project. (clasess.jar folder is empty.)
Help is appreciated!
My .gradle file of module is here,
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'WebViewOverlayvcx'
bintrayName = 'WebViewOverlayvcx'
publishedGroupId = 'org.sumitdemo'
libraryName = 'WebViewOverlayvcx'
artifact = 'WebViewOverlayVCX'
libraryDescription = 'A widget to load WebView as an Overlay.'
siteUrl = 'https://github.com/sumitdemo/mylibDemo'
gitUrl = 'https://github.com/sumitdemo/mylibDemo.git'
libraryVersion = '1.0.2'
developerId = 'sumitdemo'
developerName = 'sumit Tyagi'
developerEmail = 'sumit.k#vcloudx.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
//Add these lines to publish library to bintray
//Place it at the end of the file
//apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
And my project's .gradle file is,
// 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:2.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "http://jcenter.bintray.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now I am using "compile 'org.sumitdemo:WebViewOverlayVCX:1.0.2'" in app's .gradle file.
My Bintray Library project is here,
https://bintray.com/shashank/WebViewOverlayvcx
and you can find out my Github repo here, https://github.com/sumitdemo/mylibDemo
I researched similar questions but none of the answers solved my problem. When I try to build the starter code for a coding assignment I get the following error:
Error: Cause: Peer not authenticated
My gradle files are the following:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.sam_chordas.stockhawk"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
compile 'net.simonvt.schematic:schematic:0.6.3'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile 'com.android.support:design:23.1.1'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7#aar') {
transitive = true
}
}
I didn't manage any of those files as I don't have gradle experience yet.
Could you help me to figure out what went wrong?
Thank you very much.
P.S.:
The log files give me this error:
2016-03-23 13:01:29,664 [3912009] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/home/madelenko/Desktop/Stock-Hawk master'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Followed by a gigantic traceback.
I freshly deployed an Android library named TypedPreferences. I used it in another Android project for some days. Suddenly, it stopped working - dependencies cannot be found any longer. I noticed that Gradle only downloads one file when I clean the project:
Download http://repo1.maven.org/maven2/info/metadude/android/typed-preferences/ \
1.0.0/typed-preferences-1.0.0.aar.asc
These are build files of my pet project:
build.gradle:
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url "${System.env.HOME}/.m2/repository"
}
maven {
url "https://github.com/novoda/public-mvn-repo/raw/master/releases"
}
}
}
app/build.gradle:
apply plugin: 'android'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
compile 'com.squareup.okhttp:okhttp:1.3.+'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
compile 'com.novoda:sqliteprovider-core:1.0.+'
compile 'com.androidmapsextensions:android-maps-extensions:2.1.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'info.metadude.android:typed-preferences:1.0.0'
}
As you can see, I also enable Gradle to look into my local Maven cache here:
maven {
url "${System.env.HOME}/.m2/repository"
}
I deleted the relevant folders to avoid Gradle loading stuff from there.
There might be a misconfiguration in the build.gradle files of the library - please find them here:
Library files
Please tell me also whether I can test your fix locally without deploying to Maven Central.
Looks like the packaging element of the published POM has the wrong value. It should be aar, not aar.asc.
Also, you always can force the type of artifact to download. Just add dependency like:
compile "group:artifact:version#type"
And in your case it will be
compile "info.metadude.android:typed-preferences:1.0.0#aar"
That's it.