I can't publish an android library using maven-publish plugin - android

I have an android project inside the project I have an android module. I try to publish an maven artifact but I got the next message Publications(s) specified but no publications exist in project :.
My project build.gradle is the next:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.8.5"
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My gradle module is the next:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 29
buildToolsVersion "30.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'io.github.rockbass2560'
artifactId = 'imageprogress'
version = '1.0.0'
}
}
}
}
def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
bintray {
user = localProperties.getProperty("bintray.user")
key = localProperties.getProperty("bintray.apikey")
publications = ['release']
pkg {
repo = 'imageprogress'
name = 'imageprogress'
userOrg = user
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/rockbass2560/ImageProgress.git'
version {
name = '1.0-Final'
desc = 'First version for ImageProgress plugin'
released = new Date()
vcsTag = '1.0.0'
attributes = ['version': '1','released':true]
}
}
}
I have made tutorials on android page and other pages but I can't get fix the issue.

Related

Errors when adding firebase to a project that calls Microsoft graph

I am trying to add firebase to a existing application which involves adding:
classpath 'com.google.gms:google-services:4.3.3'
as dependency to the project level build.gradle, and adding:
apply plugin: 'com.google.gms.google-services'
as a plugin to the app level build.gradle.
The project that I am building upon is "Sign users in/out and call the Microsoft Graph from an Android app"
https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-android
Project level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: rootProject.file("gradle/versions.gradle")
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$rootProject.ext.gradleVersion"
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level build.gradle
apply plugin: 'com.android.application'
allprojects {
repositories {
mavenCentral()
google()
mavenLocal()
maven {
name "vsts-maven-adal-android"
url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
credentials {
username System.getenv("ENV_VSTS_MVN_ANDROIDADAL_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDADAL_USERNAME") : project.findProperty("vstsUsername")
password System.getenv("ENV_VSTS_MVN_ANDROIDADAL_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDADAL_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")
}
}
jcenter()
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "[com.*.*]"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("../gradle/debug.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "main"
productFlavors {
local {
// To be used with android-complete only.
// So that it could look for the 'local' flavor in Broker projects.
matchingFallbacks = ['local']
}
external {}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion"
implementation "com.google.android.material:material:$rootProject.ext.materialVersion"
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.volley:volley:1.1.1'
if (findProject(':msal') != null) {
// For developer team only.
localImplementation project(':msal')
externalImplementation 'com.microsoft.identity.client:msal:1.0.+'
} else {
// Downloads and Builds MSAL from maven central.
implementation 'com.microsoft.identity.client:msal:1.0.+'
}
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
Below is versions.gradle
// Variables for entire project
ext {
// SDK
minSdkVersion = 16
automationAppMinSDKVersion = 21
targetSdkVersion = 27
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
// Plugins
gradleVersion = '3.2.1'
androidMavenGradlePluginVersion = "1.4.1"
// Libraries
annotationVersion = "1.0.0"
appCompatVersion = "1.0.2"
browserVersion = "1.0.0"
dexmakerMockitoVersion = "1.4"
espressoCoreVersion = "3.1.0"
gsonVersion = "2.8.5"
junitVersion = "4.12"
legacySupportV4Version = "1.0.0"
localBroadcastManagerVersion = "1.0.0"
materialVersion = "1.0.0"
mockitoCoreVersion = "2.18.3"
mockitoAndroidVersion = "2.18.3"
multidexVersion = "2.0.1"
powerMockVersion = "1.6.6"
nimbusVersion = "5.7"
runnerVersion = "1.2.0"
rulesVersion = "1.2.0"
// TODO: adal automation test app.
supportLibraryVersion = "27.1.+"
adalLegacy = "1.15.0"
}
Error when syncing project
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
Caused by: java.lang.NoSuchFieldError: ASCII
at com.android.build.gradle.BasePlugin.checkPathForErrors(BasePlugin.java:1006)
at com.android.build.gradle.BasePlugin.apply(BasePlugin.java:261)
at com.android.build.gradle.AbstractAppPlugin.apply(AbstractAppPlugin.java:122)
at com.android.build.gradle.AppPlugin.apply(AppPlugin.java:43)
I had the same problem. I was able to solve it by using classpath 'com.google.gms:google-services:4.0.0' instead of classpath 'com.google.gms:google-services:4.3.3'. Build this to see another type of error. Then do invalidate cache and restart on Android studio from the File menu. Then on restart, your build should be successful. You might also need to use 'com.google.firebase:firebase-analytics:16.0.0' instead of the current version

Maven Repository on Github not downloading transitive dependencies

I have created a maven repository and uploaded it to Github. When I add it as a dependency to a sample project, the gradle sync completes successfully. But when I try to run the app, it crashes with a java.lang.NoClassDefFoundError.
Link to repository: https://github.com/rjain90/sdk
Sample project code:
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
kotlin_version = '1.3.20'
realm_version = '5.8.0'
}
repositories {
google()
jcenter()
maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:$realm_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
lifecycle_version = '2.0.0'
android_support_version = '1.1.0-alpha01'
legacy_support_version = '1.0.0'
constraint_version = '1.1.3'
retrofit_version = '2.4.0'
dagger_version = '2.16'
rxjava_version = '2.1.7'
rxandroid_version = '2.0.1'
}
Module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
// Load keystore
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
release {
keyAlias keystoreProperties['ANDROID_KEY_ALIAS']
keyPassword keystoreProperties['ANDROID_KEY_PASSWORD']
storeFile file(keystoreProperties['ANDROID_KEYSTORE_LOCATION'])
storePassword keystoreProperties['ANDROID_STORE_PASSWORD']
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.bowstring.godworld"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.release
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.appcompat:appcompat:$android_support_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation "androidx.legacy:legacy-support-v4:$legacy_support_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.cabfare.android:sdk:0.0.18#aar'
}
For GitHub hosted, you can use https://jitpack.io as a Maven repository.
Add maven { url 'https://jitpack.io' } into the project build.gradle's allprojects -> repositories block, then in your module build.gradle, add a dependency implementation 'com.github.rjain90:sdk:0.0.17', for example.
However, your two releases are both containing build errors. Solve them first.

Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom'

Getting error while using Add Firebase Authentication to your App in the Firebase authentication (Assistant).
The error shows in the Sync tab as:
Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom'. Received status code 405 from server: Method Not Allowed
Enable Gradle 'offline mode' and sync project
My Android Studio Details are:
Android Studio version 3.2.1
Gradle version: 4.6
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (App)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
}
Try to change the following code (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And (app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android { lintOptions { abortOnError false }
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.1.0'
}
Also in gradle-wrapper.properties add this line or change if already exist with other value:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Just remove :15.0.0 from the firebase implementation!
The implementation should be like:
implementation 'com.google.firebase:firebase-auth:16.1.0'
Else every thing seems fine!

ext property inside top level build.gradle file

I'm developing an android application. I've an 'dependencies.gradle' file in the root project:
ext {
// Android
kotlinVersion = '1.2.51'
gradleVersion = '3.1.3'
}
The problem is that I can use this properties in the App 'build.gradle' file but can't use inside Root 'build.gradle' file and it gives me this error:
Could not get unknown property 'kotlinVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
This is my 'Root Build Gradle':
apply from: 'dependencies.gradle'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my 'App Build Gradle' :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.shimibox.client"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I've found the problem. The ext must be inside the buildscript block. So I moved the apply from: 'dependencies.gradle' inside of that block.
Now Root build.gradle file is:
buildscript {
apply from: 'dependencies.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

Gradle install error: Javadoc

I am trying to upload a android library automatically into bintray.
I have this app gradle code:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
ext {
bintrayRepo = 'maven'
bintrayName = 'CurrentCenterPositionMap'
publishedGroupId = 'renatamelo#patriauto.org'
libraryName = 'CurrentCenterPositionMap'
artifact = 'current-center-position-map'
libraryDescription = 'A library to mark the center of a map with moveing animations'
siteUrl = 'https://github.com/leandroBorgesFerreira/CurrentCenterPositionMap'
gitUrl = 'https://github.com/leandroBorgesFerreira/CurrentCenterPositionMap.git'
libraryVersion = '0.8.1'
developerId = 'leandroBorgesFerreira'
developerName = 'Leandro Borges Ferreira'
developerEmail = 'lehen01#gmail.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 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
}
// Place it at the end of the file
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
And this project gradle:
buildscript {
ext.kotlin_version = '1.0.4'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// 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
}
But when I run:
./gradlew install
I get this error:
javadoc: error - Illegal package name: "/Users/hinovamobile/Desktop/Leandro/projetinhos/CurrentCenterPositionMap/mapfragmentwrapper/src/main/java/br/com/simplepass/mapfragmentwrapper/MapFragmentWrapper.kt"
1 error
:mapfragmentwrapper:javadoc FAILED
So what I am doing wrong? I'm not sure how to fix this error in the Javadoc...
Try using gradle-fury's scripts to generate javadoc. It does a different version for each android variant, supports umldocs via graphviz, the doc-html folder structure and more. For both Java and Android
Once the scripts are applied to your setup, make the javadocs via
gradlew install -Pprofile=javadoc
https://github.com/gradle-fury/gradle-fury
In your main gradle file, add the following lines:
tasks.withType(Javadoc).all {
enabled = false
}
Note: this will still normally show the javadocs when you press control + space on top of a class or method.
If you want to read more details check this link: https://github.com/novoda/bintray-release/issues/71

Categories

Resources