Vsts Build for Xamarin Android fails - android

I receive on my hosted (Hosted VS2017) VSTS Build the following error:
COMPILETODALVIK(0,0): Error :
Processed: ##vso[task.logissue type=Error;sourcepath=COMPILETODALVIK;linenumber=0;columnnumber=0;code=;]
COMPILETODALVIK : UNEXPECTED TOP-LEVEL error : [d:\a\1\s\src\Android\Android.csproj]
Exception in thread "main"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
The build locally works without errors.

Thanks to #Milen to add the link.
Increasing the Java Max Heap Size to 1G in my project solves the problem. You will found this configuration in your project properties under Android Options and the click the button Advanced.
ATTENTION: Do this in the build configuration where you need it. I added it to both Debug and Release.

Related

Failed build Project after change directory to external storage; Timeout waiting to lock Java compile cache (/.gradle/7.0.2/javaCompile)

I have an issue when building project after created a new project in different volumes in Mac Os.
This what error said :
Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().
> Timeout waiting to lock Java compile cache (/Volumes/SDMICRO/ANDROID/AwPlayerTes/.gradle/7.0.2/javaCompile). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 2394
Owner Operation: unknown
Our operation:
Lock file: /Volumes/SDMICRO/ANDROID/AwPlayerTes/.gradle/7.0.2/javaCompile/javaCompile.lock
Actually this is not my true directory in development project. But i have no choices because of run out of space. But this project are failure build. I have tried some solution like this. But none of them are works, FYI i use Mac and Android Studio Archtic Fox.
Please someone help me
please try to delete the Lock file, and then rebuild the project.
I encoutered the same problem and already solved it.

Can't compile React Native Android APK, fails on bundleReleaseJsAndAssets/metro-bundler

I am getting the following errors compiling on Android, either from the command line or via Android Studio:
* Exception is:
org.gradle.api.UncheckedIOException: Failed to capture snapshot of input files for task 'bundleReleaseJsAndAssets' during up-to-date check
Caused by: java.io.FileNotFoundException: /Users/mikem/react/myapp/metro-bundler-symbolicate117923-49160-k3nnyf.htls935wmi.sock (Operation not supported on socket)
I have cleared out node_module and reset the caches, manually generated the bundle but this error continues.
Any help would be appreciated.
In case anybody else runs into this - the link metro-bundler-symbolicate117923-49160-k3nnyf.htls935wmi.sock did exist in that directory but had a root owner (perhaps could have been caused when I was trying to fix other issues). Deleting the link fixed the problem.

Increasing PermGen space for Jenkins/gradle

I am running a Jenkins build of an Android project on a Mac Mini (10.9.5). The Jenkins build is failing with error messages like this:
<package>.myTest > test_myTest FAILED
org.mockito.cglib.core.CodeGenerationException at test_myTest.java:65
Caused by: java.lang.reflect.InvocationTargetException at test_myTest.java:65
Caused by: java.lang.OutOfMemoryError at test_myTest.java:65
java.lang.OutOfMemoryError: PermGen space
This is sometimes followed by messages like
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "/0:0:0:0:0:0:0:1:50340 to /0:0:0:0:0:0:0:1:50339 workers Thread 2"
16:47:17
16:47:17 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "/0:0:0:0:0:0:0:1:50340 to /0:0:0:0:0:0:0:1:50339 workers Thread 4"
16:47:18
16:47:18 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "/0:0:0:0:0:0:0:1:50340 to /0:0:0:0:0:0:0:1:50339 workers Thread 5"
16:47:18
16:47:18 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "/0:0:0:0:0:0:0:1:50340 to /0:0:0:0:0:0:0:1:50339 workers Thread 6"
16:47:19
It usually fails at the same point in the build. According to the Jenkins wiki
Do you consistently see OOME around the same phase in a build? If so, maybe it just needs a bigger memory.
this may mean I just need more PermGen space.
The stackoverflow posts/blog posts I've read indicate that I need to increase the max PermGen size (-XX:MaxPermSize=1024M, for example). However, I'm not clear on where to do this.
I've changed this for GRADLE_OPTS and JAVA_OPTS so my Jenkins build environment looks like this:
As seen in the screenshot, I also added some options to garbage collect Perm Gen as recommended here.
This seemed to be working--I had a few successful builds yesterday, but it's now failing again (with no changes that I'm aware of).
After reading this answer, I also changed the following line in my project's gradle.properties file.
org.gradle.jvmargs=-Xms1024M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=2048 -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
This hasn't fixed the problem.
Answers to similar questions like this and this make me think I may be approaching this the wrong way--should I be changing a computer setting for the Mac (10.9.5) which is running Jenkins? What is the correct way to modify the PermGen space?
Edit: I had previously thought that perhaps the environmental variables weren't being set, but I verified that they appear under the build result Environmental Variables (jenkins/job/<Project>/146/injectedEnvVars/)
As Integrating Stuff said, it was necessary to increase the MaxPermSize for the unit tests. I found how to do so here in the "Running from Gradle" section.
android {
testOptions {
unitTests.all {
jvmArgs '-XX:MaxPermSize=1024m' //prevent OOM (PermGen space) while running tests
}
}
...
}
The memory settings are set per running JVM process. So you definitely do not need to set any OS variables or system wide settings to fix this.
You first need to determine which process is throwing the error.
I am assuming it is the Gradle build and not the Jenkins itself.
It it is the Gradle build, you still do not know which process.
By default, the Gradle Test task executes the tests in a separate jvm, so changing the values in gradle.properties will not help you in such a case.
In such case, you need to configure your Gradle Test task correctly, for example:
test {
jvmArgs "-XX:MaxPermSize=2048m"
}

Jenkins failing robolectric test cases...!

I am trying to build my android project on Jenkins 2.0 server on Ubuntu machine.
I am running the following commands for that purpose:-
./gradlew clean (this is working fine)
./gradlew build (this is failing random number of test cases)
However I also install Jenkins 2.0 on my Windows 7 machine and run the same commands as above, and it was passing all test cases every time. I am not understanding what is wrong with that.
I did lot of debugging but could not find any solution, please help me to get rid out of this thing...!
This is my 34th build log on Jenkins
testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
48 tests completed, 2 failed
:app:testDebugUnitTest FAILED
This is my 35th build log on Jenkins without making any code changes
> handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreconditions FAILED
java.lang.NullPointerException at UpdateTabFragmentTest.java:30
> testPreconditions FAILED
java.lang.NullPointerException at ServiceTabFragmentTest.java:29
> testPreConditionIsNotNull FAILED
java.lang.NullPointerException at HomeActivityTest.java:63
48 tests completed, 5 failed
:app:testDebugUnitTest FAILED
You should check the Jenkins console output for something like
"WARNING: No manifest file found " in the console output.
Those NPEs are typical for missing resources.
The most common source for failing robolectric builds on different environmnets is probably robolectric not beeing able to load any resources.
Since robolectric needs to know where your Android Manifest is, you may have to provide a extra robolectric.properties for the build
http://robolectric.org/configuring/

Is there a way to make DexGuard exit with an error condition if an error occurs?

I'm currently building an android application using ANT on a Jenkins server.
DexGuard is set to run on release in the custom_rules.xml.
Currently there is an issue when DexGuard tries to convert a method:
[dexguard] Unexpected error while converting:
[dexguard] Class = [o/?]
[dexguard] Method = [?(Ljava/lang/String;)Lo/?;]
[dexguard] Exception = [java.lang.IllegalStateException] (Variable v17 too large for instruction [neg-int v17, v17])
[dexguard] java.lang.IllegalStateException: Variable v17 too large for instruction [neg-int v17, v17]
...
Stack trace
...
[dexguard] Not converting this method
My question is, is there a way to get DexGuard to exit with an error status so that either ANT or Jenkins can mark the build as failed?
At the moment it simply prints the stack trace and continues.
I am currently using the Text-finder plugin for Jenkins as a post build step to match a DexGuard exception. If found it downgrades the build to failed.
DexGuard currently ignores methods that it can't convert from Java bytecode to Dalvik bytecode, for any reason -- notably corrupt input code. In this case, it looks more like a bug in DexGuard itself. We'll fix it as soon as possible, and we'll consider adding a flag to stop with an error status.
(I am the lead developer of ProGuard and DexGuard)

Categories

Resources