Cannot publish library due to javadoc task errors - android

I have a library I'm trying to publish using the bintray plugin's bintrayUpload task. When the script runs the javadoc task, it is filled with many errors, because the javadoc task evidently cannot read references to classes in dependencies of my library module. For example:
error: package androidx.preference does not exist
import androidx.preference.Preference;
When I run gradlew javadoc, it completes without errors. I'm not sure exactly how the bintrayUpload task operates. Is it calling that same javadoc task that I am? And either way, how do I configure it to be able to see the classes of my dependencies from androidx?
In my top level build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
In my library module's build.gradle:
apply from: '../bintray-setup.gradle'

Related

"Unable to resolve dependency for" after performing Build/Make Project after update to Bumblebee

After updating Android Studio to Bumblebee 2021.1.1 Patch 2 I encountered failures that I hadn't before. For example, after a Build/Make Project attempt under Build/Sync there are 23 messages of the form:
Failed to resolve: com.squareup.leakcanary:leakcanary-android:2.8.1
Show in Project Structure dialog Affected Modules: app
I searched for com.squareup.leakcanary and found that it is not at the repository set in build.gradle, so I added that repository to my build.gradle file as the second URL under allprojects/repositories as I believe that Declaring repositories intends:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
//jcenter()
mavenCentral()
}
dependencies {
def nav_version = "2.4.1"
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
//jcenter()
google()
maven { url 'https://maven.google.com' }
maven { url 'https://mvnrepository.com/artifact/com.squareup.leakcanary'}
//maven { url 'https://mvnrepository.com/'}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The following warning is found under Build Output:
Could not HEAD
'https://mvnrepository.com/artifact/com.squareup.leakcanary/com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'.
Received status code 403 from server: Forbidden Disable Gradle
'offline mode' and sync project
Clicking on the URL in that message results in the following from mvnrepository.com:
Not Found For request 'GET
/com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'
Obviously the process made a call that was rebuffed. The following line for leakcanary is in my app build.gradle (app) file:
// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
According to Getting started that is all that is required to use leakcanary, which is why I use it as an example, it fails now when it worked before as shown on that web page.
Something happened with this update that led to gradle not being able to resolve dependencies that it did previously. I have 23 of these to deal with and would like to understand what is going on and what I can't see in the Bumblebee update information or the Gradle documentation. I've read Verifying dependencies, but a resolution does not jump out at me.
All of the stackoverflow search results mentioned doing one of the following that I have ensured were done:
Offline mode is disabled
Performed File/Invalidate caches
Commented out jcenter() as its no longer receiving updates
Updated current revisions in build.gradle (app)
Performed Build/Clean Project
Followed all suggestions in Bumblebee update and subsequent ones identified in build.gradle (app) for the individual dependency revisions

Trying to add module to project. Gradle DSL method not found: 'versionName()'

I am trying to add a epub reader library to a project I have already created. The library I am trying to add to my project as a moduel is the Folio Reader Library (https://github.com/FolioReader/FolioReader-Android). I have downloaded this library on my computer and have tried adding it through File -> New -> Import Module. However, during the process I received countless errors. My current one is this:
Gradle DSL method not found: 'versionName()'
Possible causes:
The project 'FolioReader-Android-master' may be using a version of the
Android Gradle plug-in that does not contain the method (e.g.
'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project
The project 'FolioReader-Android-master' may be using a version of Gradle
that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
This file is the file where the dependencies are declared for the Library.
FolioReader-Android-master:
build.gradle file:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
apply from: 'versions.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//moj
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
allprojects {
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error itself states that the problem arises because the project is using a version of the Gradle plug-in may not contain the method. I have updated the version to the newest one, however I still receive this error. Any suggestions on how I can solve this problem?
Problem solved by replacing
versionName 1
with
versionName "1.1"
in the Module level build.gradle file.

Excecution failed for task ':app:preDebugAndroidTestBuild'

I am completely new to android and kotlin programming. I just started learning android since yesterday. I have successfully created a project but it doesn't show me xml editor.
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
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
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any idea to solve this problem
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:26.1.0'
}
}
Add the above line in your app.gradle file before dependencies block & replace compile to implementation.
In Android Studio , click on Terminal and execute this command.
gradlew app:dependencies
and then search for com.android.support:support-annotations.
Then in your app level gradle file , exculude the com.android.support:support-annotations dependency from the dependency which has the older version i.e 26.1.0. To learn how to exuclude go here.

Cannot add Google Play Location Service as dependency to my Android Project

I tried to add the Google location Service to my Android Project by referencing the official link.
As the tutorial said I added the following line to the dependencies section in the Project Gradle file.
implementation "com.google.android.gms:play-services-location:11.8.0"
But when i resynced the project i got the following error
Error:(19, 0) Could not find method implementation() for arguments [com.google.android.gms:play-services-location:11.8.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
I am using Android Studio 3.0.1 and Gradle Version 4.1.
How to overcome this error?
please try this
Add in Build.gradel at app lavel
dependencies {
Implementation 'com.google.android.gms:play-services:9.6.0'
}
apply plugin: 'com.google.gms.google-services
// 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:3.0.0'
classpath 'com.google.gms:google-services:3.0.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
}
I think you have forgot to add maven repository in your app gradle file. Try by doing these steps. Open the build.gradle file for your application. Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example: allprojects {repositories {jcenter()maven {url "https://maven.google.com"}}}
Avoid using + in your dependencies as it android studio will try to update dependencies every 24 hours. Also replace compile by implementation for low APK size.
Edit 1:
As you told maven repository did not worked.
Check your project settings by going to Android Studio.
Click on file
click on project structure
There will option of Project in sidebar. Tap on it.
Check for the gradle and andrpid plugin version.
Put these values
Gradle Version - 4.1
Android plugin version - 3.0.1
Android Plugin Repository - jcenter,google()
Default Library Repository - jcenter, 'https://maven.google.com'
Reply me if it works

Exception : mergeDebugResources in Android Studio

I got following Error if I try to add dependency in Top - level build.gradle file. This dependency is very much useful to add GCM in project without it GCM won't work:
Dependency :
classpath 'com.google.gms:google-services:1.5.0-beta2'
Error :-
Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details
If I remove that dependency from top-level build.gradle the project compiles and run successfully.
If I add that file I got the error and Android Studio do not run project.
Please help me to get out of this error.
Edit
Here is my project level build.gradle file:-
// 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.0.0-alpha6'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
// 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
}
try Changing latest version of dependency from HERE:
classpath 'com.google.gms:google-services:2.0.0-beta5'
Also make sure you are setting correct Gradle plugin dependency as well in root project gradle file.
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
So, your final project build.gradle file will look like
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
}
Try this it should help.
buildTypes {
release {
multiDexEnabled true;
}
}
in your Gradle log, if you're getting bad/invalid PNG file then take a look at my answer at Android Studio Gradle 2.0.0-alpha1 build errors
Hope this helps...

Categories

Resources