I'm working on an Android project and trying to generate javadoc with the task below, but it doesn't generate anything.
I have tried to trace back the issue to changes in the project. Checking out past commits and trying to create javadoc fails, even though in the past it worked.
The only thing for sure that changed for me that might explain this behaviour is the upgrade to a newer version of macOs Big Sur and updating Android Studio.
Does anyone have an idea what the problem might be?
Setup:
macOS Big Sur Version 11.4
Android Studio 4.2.1
Gradle 6.5
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
options.memberLevel = JavadocMemberLevel.PUBLIC
failOnError = false
source = variant.javaCompiler.source
def androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
doFirst {
classpath = files(variant.javaCompile.classpath.files) + files(androidJar)
}
options {
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
}
}
Well after a long time of searching I found the answer: it was the update from AS 4.1.3 to 4.2.x with which Google decided to package Java11 instead of 8.
Building and compiling was possible, but javadoc generation was broken for whatever reason.
Related
I have created a benchmark module and within its build.gradle file I have added a managed device as following:
testOptions {
managedDevices {
devices {
pixel2api30 (com.android.build.api.dsl.ManagedVirtualDevice) {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp"
require64Bit = false
}
}
}
}
Whenever I run the command gradle :benchmark:pixel2api30Setup its working
But when I run the command gradle :benchmark:pixel2api30BenchmarkAndroidTest
It throws the following error:
Task 'pixel2api30BenchmarkAndroidTest' not found in project ':benchmark'.
Which version of AGP are you using?
I was getting similar error but after upgrading AGP to 7.3.0-alpha07 from 7.2.2, I can now run the benchmark instrumentation task.
As stated in the release preview notes:
Make sure your project is using AGP version 7.3.0-alpha07 or higher.
https://developer.android.com/studio/preview/features?hl=fr
When trying to upload my application (aab) to the play store - Im seeing this error, and I cant find anyone talking about it. The error message is translated from Swedish -> English using Google Translate.
The versions used are 0, and 12451000. Its clear to me that the 0 is a mistake, but Ive now spent several days trying to figure out where the 0 is coming from without any success.
Things Ive tried;
Export the aab using different versions of Android Studio. Ive tried stable, beta & canary.
Reduce versions of my dependencies to the ones I know have worked in the past.
Update dependencies, gradle, libraries, etc.
Invalidate caches, reinstall Android Studio, wipe its settings and follow its 'repair IDE' wizard.
Verify that build.gradle and plugins are written & used correctly.
My usage of the play services is quite broad, I apply them in my app/phone module with an additional line in my plugins block id 'com.google.gms.google-services'. The root build.gradle contains the classpath to com.google.gms:google-services.
My full related dependencies are as follows (declared in TOML);
firebase-gradle = { module = 'com.google.firebase:firebase-crashlytics-gradle', version = '2.8.1' }
firebase-bom = { module = 'com.google.firebase:firebase-bom', version = '29.3.0' }
firebase-crashlytics = { module = 'com.google.firebase:firebase-crashlytics-ktx' }
firebase-auth = { module = 'com.google.firebase:firebase-auth-ktx' }
firebase-database = { module = 'com.google.firebase:firebase-database-ktx' }
google-gradle = { module = 'com.google.gms:google-services', version.ref = 'google-services' }
google-auth = { module = 'com.google.android.gms:play-services-auth', version.ref = 'google-auth' }
google-fitness = { module = 'com.google.android.gms:play-services-fitness', version.ref = 'google-fitness' }
google-services = '4.3.10'
google-auth = '20.1.0'
google-fitness = '21.0.1'
At this point Im looking for any guidance I can get. Are there any additional troubleshooting steps I can take? Have you experienced something similar in the past? Please let me know.
This could be a versioning problem. Try changing the
com.android.application and com.android.library
versions from 7.3.0-alpha 07 to 7.1.2.
Alternatively, try the remedy below
androidComponents {
onVariants(selector().all(), {
def capitalizedVariantName = name.substring(0,1).toUpperCase() + name.substring(1)
afterEvaluate {
tasks.named("map${capitalizedVariantName}SourceSetPaths").configure {
it.dependsOn("process${capitalizedVariantName}GoogleServices")
}
}
})
}
The issue has been fixed and closed. Check it here on Issue Tracker
The work around could be unnecessary.
I defined manifest placeholders for different variants using following code.
android.applicationVariants.all { variant ->
// def names = variant.getVariantData().getVariantConfiguration().getFlavorName()
def mergedFlv = variant.getVariantData().getVariantConfiguration().getMergedFlavor()
mergedFlv.manifestPlaceholders = [pl1: mergedFlv.getApplicationId() + mergedFlv.getApplicationIdSuffix()]
It was working well. But I updated to the latest version of Android Studio a week ago and also updated gradle version for this project when Android Studio prompted and the Android Studio throws following error.
No signature of method: com.android.build.gradle.internal.variant.ApplicationVariantData.getVariantConfiguration() is applicable for argument types: () values: []
How do I fix this?
Update
I found this class at https://android.googlesource.com/platform/tools/build/+/0d498ccf6f91a12c036b382b7ae2b1a809eb2b9d/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApplicationVariantData.java
It does not have getVariantConfiguration() method. But it is extending ApkVariantData class which in turn is extending BaseVariantData. BaseVariantData has this public method getVariantConfiguration()
Thus it should be accessible. I closed and reopened project as well as android studio and tried building project again too... Doesn't seem to work.
Any help please
As of now I downgraded my Android Gradle Plugin Version from 4.0.0 to 3.6.3 and Gradle Version from 6.5.1 to 5.6.4 following this answer (method to downgrade) and it worked.
There seems to be problem/bug with Gradle.
Refer this post.
I think this may no longer work. See Android 4.0 Known Issues - Variant Output
Try this instead:
android.applicationVariants.all { variant ->
// def names = variant.getFlavorName()
def mergedFlv = variant.getMergedFlavor()
mergedFlv.manifestPlaceholders = [pl1: mergedFlv.getApplicationId() + mergedFlv.getApplicationIdSuffix()]
It worked for me.
Since update to Android Studio 3.3 we get a weird warning with some legacy code about encrypted gradle parameters.
In build.gradle we have this line:
apply from: "encryption.gradle"
In encryption.gradle we have this content:
afterEvaluate {
android.applicationVariants.all { variant ->
def pwd = "";
variant.productFlavors.each { flavor ->
if (flavor.ext.has("pwd1")) {
pwd = flavor.ext.pwd1
}
}
if (pwd.isEmpty() && variant.buildType.ext.has("pwd2")) {
pwd = variant.buildType.ext.pwd2
}
variant.resValue 'string', 'pwd', encryptPassword(pwd, variant.signingConfig, variant.applicationId)
}
}
def String encryptPassword(String password, signingConfig, String applicationId) {
...
}
In the code we use it like this:
getString(R.string.pwd)
And since the AS update we get the following error:
Cannot resolve symbol 'pwd'
When compiling/building the project everything runs fine because it can find the parameter. But when working in the IDE, all files that try to use R.string.pwd are marked red and show the error message, which is pretty annoying.
Any way to make this go away easily? SuppressWarnings("all") and SuppressLint("all") are not helping.
Is afterEvaluate the right place to do this or would it be better somehow in the defaultConfig section of build.gradle?
Even i was facing similar issues. so i reverted my gradle to 3.2.1 and it works as expected, it might be a technical glitch/issue with gradle 3.3
While i was on gradle 3.3 i tried invalidating cache for android studio, restarted it etc, but nothing solved the issue.
I'm trying to get around an annoying issue with Gradle that does not allow libraries to have different min/target sdk's. The solution was to add the following to build.gradle.
android.applicationVariants.all{ variant ->
// This is an annoying hack to get around the fact that the Gradle plugin does not support
// having libraries with different minSdkVersions. Play Services has a min version of 9 (Gingerbread)
// but Android Maps Utils supports 8 (Froyo) still
variant.processManifest.doFirst {
File manifestFile = file("${buildDir}/exploded-bundles/ComGoogleMapsAndroidAndroidMapsUtils03.aar/AndroidManifest.xml")
if (manifestFile.exists()) {
println("Replacing minSdkVersion in Android Maps Utils")
String content = manifestFile.getText('UTF-8')
content = content.replaceAll(/minSdkVersion="8"/, 'minSdkVersion=\"9\"')
manifestFile.write(content, 'UTF-8')
println(content)
}
}
}
However when i do that, I get an error that applicationVariants cannot be resolved. How do I fix this?
Aparrently, this is an Android Studio bug and is telling me there are errors where there's none. Building and ignoring works fine.