I'm porting a C# library to Kotlin to take advantage of multiplatform. When running the build task, it fails in the subtask linkDebugTestLinux.
For context, I'm using IDEA Ultimate on Manjaro. I'm certain there's nothing wrong with my code as compileKotlinLinux finishes without error.
There are zero DDG results for "linkDebugTestLinux" and nothing helpful for "konan could not find home" or "kotlin native ...". After hours of stitching together incomplete and outdated examples from the official docs, I've given up.
My build.gradle.kts:
plugins {
kotlin("multiplatform") version "1.3.40"
}
repositories {
mavenCentral()
}
dependencies {
commonMainImplementation("org.jetbrains.kotlin:kotlin-stdlib")
commonTestImplementation("org.jetbrains.kotlin:kotlin-test-common")
commonTestImplementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
kotlin {
// js() // wasn't the issue
linuxX64("linux")
}
Output of task build without args:
> Configure project :
Kotlin Multiplatform Projects are an experimental feature.
> Task :compileKotlinLinux
[...unused param warnings...]
> Task :compileKotlinMetadata
[...unused param warnings...]
> Task :metadataMainClasses
> Task :metadataJar
> Task :assemble
> Task :linuxProcessResources NO-SOURCE
> Task :linuxMainKlibrary
> Task :linkDebugTestLinux FAILED
e: Could not find "/home/username/" in [/home/username/path/to/the/repo, /home/username/.konan/klib, /home/username/.konan/kotlin-native-linux-1.3/klib/common, /home/username/.konan/kotlin-native-linux-1.3/klib/platform/linux_x64].
[...snip...]
BUILD FAILED in 16s
4 actionable tasks: 4 executed
Process 'command '/usr/lib/jvm/java-8-openjdk/bin/java'' finished with non-zero exit value 1
In the boilerplate I omitted it suggests to use --debug, so I've uploaded that here.
After some investigation, it was assumed that the problem is in the path. In the debug log, you got the /home/yoshi/,/ fragment. As far as this directory name was unexpected, the compiler interpreted this , as a delimiter between lib names. So, it tried to find library /home/yoshi/, that was obviously unavailable.
For now, I would recommend you to change the directory name to be something trivial.
Related
I'm trying to use https://github.com/brim-borium/spotify_sdk in Android Studio with Flutter
As such, I need to import Spotify SDK (two AAR files), and to be able to add them to the build process.
Because of spotify_sdk (flutter package), I can't use (which seem to work)
implementation (name: 'spotify-app-remote', ext: 'aar')
implementation (name: 'spotify-auth', ext: 'aar')
in my project, I specifically need Gradle to consider spotify-app-remote & spotify-auth as projects, because spotify_sdk imports them like this.
implementation project(':spotify-auth')
implementation project(':spotify-app-remote')
Here is the Gradle error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve project :spotify-auth.
Required by:
project :app
> No matching configuration of project :spotify-auth was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- None of the consumable configurations have attributes.
> Could not resolve project :spotify-app-remote.
Required by:
project :app
> No matching configuration of project :spotify-app-remote was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- None of the consumable configurations have attributes.
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
Here is my settings.gradle
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
So I need to be able to force Gradle to import these AAR as a projet.
Here is my project structure, if it useful
Project Structure
From documentation and StackOverflow posts, I've read that Android Studio used to have an Import AAR/Jar file functionality. It is now missing in Android Studio 4.2
Is there any functionality that replaces Import AAR/Jar file? Or any way to force Gradle to recognize these files as projects?
Thank you very much
Can you advise how to configure the plugin verifier so it would return errors as JetBrains marketplace does, please?
Error from the marketplace:
[plugin] depends on plugin com.jetbrains.php that couldn't be resolved with respect to IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4)
Note that the [plugin] cannot be installed into IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4) without mandatory com.jetbrains.php
Found 1 incompatibility with IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4), some of which may be caused by the missing dependencies.
When running runPluginVerifier locally everything is fine:
2020-12-11T13:01:29 [main] INFO verification - Finished 1 of 2 verifications (in 3.1 s): IU-202.8194.7 against com.lokalise.jetbrainsideplugin:1.0.0-alpha: Compatible
2020-12-11T13:01:30 [main] INFO verification - Finished 2 of 2 verifications (in 3.6 s): PS-202.6948.87 against com.lokalise.jetbrainsideplugin:1.0.0-alpha: Compatible
I would like to catch such an error during CI at most instead of throwing the plugin at the marketplace team.
Here is the gradle task configuration (Kotlin):
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
...
tasks.runPluginVerifier {
ideVersions("PS-202.6948.87,IU-202.8194.7")
setFailureLevel(RunPluginVerifierTask.FailureLevel.ALL)
}
I struggled with it quite a bit. Found it.
tasks {
runPluginVerifier {
ideVersions.set(listOf("PS-202.6948.87","IU-202.8194.7"))
}
...
}
Is it possible to make Android Studio build fail on lint check errors ?
I have problems with ImageViews when I convert icon from .png to vector drawable .xml
Sometimes I forgot to change
android:src="#drawable/ic_minus"
to
app:srcCompat="#drawable/ic_minus"
and the app crashes on older OS devices.
?
If there's a lint check for that you can change the severity to FATAL and then when building the release version of your APK it should fail.
android {
lintOptions {
fatal 'MY_LINT_CHECK_ID'
}
}
Also you can execute the Gradle lint task which will fail. If you also want warnings to let your build fail you can use this.
android {
lintOptions {
warningsAsErrors true
}
}
You can also use the below code inside android block in module/app level build.gradle file
For build.gradle
android {
applicationVariants.all {
// Example lint task, your verification task can be anything
def lintTask = tasks["lint${name.capitalize()}"]
assembleProvider.get().dependsOn(lintTask/*, detekt*/) // add list of all the tasks which should fail the build
}
}
For build.gradle.kts(Kotlin DSL)
android {
applicationVariants.all {
// Example lint task, your verification task can be anything
val lintTask = tasks["lint${name.capitalize()}"]
assembleProvider.get().dependsOn.addAll(listOf(lintTask/*, tasks["detekt"]*/)) // add list of all the tasks which should fail the build
}
}
Above code makes the build assemble task which run when we run build app or run app, depends on the listed verification tasks and hence fails it when those tasks fails
Make sure your verification tasks(in our case lint task) are set to fail the build when they are run and there are some issues found in them. All verification tasks has their own flags to enable this behaviour.
For lint you can enable the build failure on warning as below(build.gradle.kts for Kotlin DSL)
android {
lint {
isWarningsAsErrors = true
}
}
I have a situation to build multiple solution using MSBUILD in multi threading, but during build, always few solution get failed. I have try to build each solution one by one , its working perfectly. but i have try to build 5 solution using multi threading, few build get failed. As I investigated the build log file of both success build and failure build, it seems MSBUILD getting conflict with each build process. For reference I have attached two text file of build log.
[Build start for submission ID 11468 ]
https://i.stack.imgur.com/KbaJb.png
[Build start for submission ID 11468 ]
https://i.stack.imgur.com/K1BOU.png
using (BuildManager objBuildManager = new BuildManager())
{
BuildRequestData BuildRequest = new BuildRequestData(SolutionPath, GlobalProperty, "14.0", new string[]
{ "Build" }, null,
BuildRequestDataFlags.ReplaceExistingProjectInstance);
BuildResult buildResult = objBuildManager.Build(bp, BuildRequest)
if (buildResult.OverallResult == BuildResultCode.Success)
{
buildPath = Convert.ToString(buildResult.ResultsByTarget.FirstOrDefault(x =>
x.Key == "Build").Value.Items[0]);
}
}
Have attached build log for reference.
Success build log
https://github.com/Microsoft/msbuild/files/1115978/11468.success.txt
failure build log
https://github.com/Microsoft/msbuild/files/1115979/11468.failed.txt
I’m trying to define two new Gradle tasks, buildAll and pubLocal, to run other tasks in a specific order.
When gradle buildAll is invoked, I want Gradle to do the same thing as if I had executed gradle clean build writePom (see below for writePom).
When gradle pubLocal is executed, I want Gradle to do the same thing as if gradle buildAll install had been executed.
Here’s my best attempt thus far:
// build.gradle
task writePom << {
pom {
project {
groupId 'mygroup'
artifactId 'mylib'
version version
inceptionYear '2015'
licenses {
license {
name 'Blah'
url 'blah'
distribution 'blah'
}
}
}
}.writeTo("build/libs/pom.xml")
}
task buildAll(dependsOn: clean, build, writePom)
task pubLocal(dependsOn: buildAll, install)
When I run gradle buildAll on this, I get:
myuser#mymachine:~/tmp/myapp$./gradlew buildAll
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/myuser/tmp/myapp/build.gradle' line: 67
* What went wrong:
A problem occurred evaluating root project 'myapp'.
> Could not find method buildAll() for arguments [{dependsOn=task ':clean'}, task ':build', task ':writePom'] on root project 'myapp'.
Any ideas as to where I’m going awry?
This may be a left-over from copy-pasting, but your strings are not quoted consistently using standard single- or double-quotes. Example:
}.writeTo(“build/libs/pom.xml")
does not quote the string properly, as it opens with the “ character instead of ". Same with the single-quotes above it.
You can see from the way your code is highlighted, that everything in red is interpreted as a string. If this is the case in your actual code, the buildAll and pubLocal tasks will not be recognized, as they are part of a string rather than code.
UPDATE:
Since the above answer is irrelevant now, here is another possibility. The error message shows that only the "clean" task is listed in the dependsOn parameter. The buildAll task dependencies should be declared like this:
task buildAll(dependsOn: [clean, build, writePom])
Similar with the pubLocal task.
I'm using Gradle 2.4. The following file includes the Maven plugin, uses a list [] in the dependsOn, and ensures that clean must be executed before build:
apply plugin: 'maven'
task writePom << {
pom {
project {
groupId 'mygroup'
artifactId 'mylib'
version version
inceptionYear '2015'
licenses {
license {
name 'Blah'
url 'blah'
distribution 'blah'
}
}
}
}.writeTo("build/libs/pom.xml")
println "TRACER writePom"
}
task clean << { println "TRACER clean" }
task build << { println "TRACER build" }
build.mustRunAfter clean
task install << { println "TRACER install" }
task buildAll(dependsOn: [clean, build, writePom])
task pubLocal(dependsOn: [buildAll, install])
I get this output (minus Gradle 3 warnings):
bash-3.2$ gradle buildAll
:clean
TRACER clean
:build
TRACER build
:writePom
TRACER writePom
:buildAll
BUILD SUCCESSFUL
and this:
bash-3.2$ gradle pubLocal
:clean
TRACER clean
:build
TRACER build
:writePom
TRACER writePom
:buildAll
:install
TRACER install
:pubLocal
BUILD SUCCESSFUL