Xamarin and Travis-ci - android

I have a simple hello world app that fails to build. I'm getting the following output from the build.
Warnings:
/home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: warning : Could not find project file /usr/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets, to import. Ignoring.
/home/travis/build/chaione/csharptrav/csharp/csharp.Droid/csharp.Droid.csproj: warning : Could not find project file /usr/lib/mono/xbuild/Novell/Novell.MonoDroid.CSharp.targets, to import. Ignoring.
Errors:
/home/travis/build/chaione/csharptrav/csharp/csharp.sln (default targets) ->
(Build target) ->
/home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: error : /home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: /home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj could not import "$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets"
What do I need to do get this to build? The solution consist of 6 projects: Core PCL(profile 78), Android, iOS, Android UI test, iOS UI test, UnitTest (using NUnit).

I had an issue like that and moved to https://www.appveyor.com/. Here https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/appveyor.yml you can find a link to appveyor.yml which plays the role as .travis.yml. Please note that you have to have a Xamain license. The credentials are secured in the appveyor.yml file.

Related

File not Found when compiling android resources (inconsistent across projects, consistent within projects)

I have a project that uses bazel and includes a demo Android app to show some functionality and widgets. I wanted to split this out as the base for a new demo/experimentation app to try out other widget combinations. So I copied the WORKSPACE file and the code from the demo app package into a new project (the package names changed but I modified the code and BUILD files to account for this). The original project builds just fine, but the new one consistently fails with the following error:
ERROR: D:/_bazel_out/s6wwoqrr/external/maven_android_everything/BUILD:568:11: Compiling Android resources for #maven_android_everything//:com
_google_android_material_material failed: (Exit 1): ResourceProcessorBusyBox.exe failed: error executing command bazel-out\x64_windows-opt-ex
ec-2B5CBBC6\bin\external\bazel_tools\src\tools\android\java\com\google\devtools\build\android\ResourceProcessorBusyBox.exe ... (remaining 1 a
rgument skipped)
Jul 29, 2022 3:04:29 PM java.util.stream.ForEachOps$ForEachOp$OfRef accept
SEVERE: Error during Compiling bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_goog
le_android_material_material\res\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml:
Command: external\androidsdk\build-tools\33.0.0\aapt2.exe\
compile\
-v\
--legacy\
-o\
C:\Users\bdlei\AppData\Local\Temp\android_resources_tmp3839340977225638696\compiled\bazel-out\android-armeabi-v7a-fastbuild\bin\exter
nal\maven_android_everything\_aar\unzipped\resources\com_google_android_material_material\res\
bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_google_android_material_mat
erial\res\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml
Output:
bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_google_android_material_material\re
s\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml: error: file not found.
Exception in thread "main" com.google.devtools.build.android.aapt2.ResourceCompiler$CompileError
at com.google.devtools.build.android.aapt2.ResourceCompiler$CompileError.of(ResourceCompiler.java:111)
at com.google.devtools.build.android.aapt2.ResourceCompiler$CompilingVisitor.getCompiledArtifacts(ResourceCompiler.java:431)
at com.google.devtools.build.android.aapt2.ResourceCompiler.getCompiledArtifacts(ResourceCompiler.java:465)
at com.google.devtools.build.android.UnvalidatedAndroidData.compile(UnvalidatedAndroidData.java:103)
at com.google.devtools.build.android.CompileLibraryResourcesAction.main(CompileLibraryResourcesAction.java:143)
at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$6.call(ResourceProcessorBusyBox.java:99)
at com.google.devtools.build.android.ResourceProcessorBusyBox.processRequest(ResourceProcessorBusyBox.java:234)
at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:177)
Suppressed: java.lang.RuntimeException: Error during Compiling bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_eve
rything\_aar\unzipped\resources\com_google_android_material_material\res\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml:
Command: external\androidsdk\build-tools\33.0.0\aapt2.exe\
compile\
-v\
--legacy\
-o\
C:\Users\bdlei\AppData\Local\Temp\android_resources_tmp3839340977225638696\compiled\bazel-out\android-armeabi-v7a-fastbuild\bin\exter
nal\maven_android_everything\_aar\unzipped\resources\com_google_android_material_material\res\
bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_google_android_material_mat
erial\res\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml
Output:
bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_google_android_material_material\re
s\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml: error: file not found.
at com.google.devtools.build.android.CommandHelper.execute(CommandHelper.java:42)
at com.google.devtools.build.android.AaptCommandBuilder.execute(AaptCommandBuilder.java:297)
at com.google.devtools.build.android.aapt2.ResourceCompiler$CompileTask.compile(ResourceCompiler.java:234)
at com.google.devtools.build.android.aapt2.ResourceCompiler$CompileTask.call(ResourceCompiler.java:178)
at com.google.devtools.build.android.aapt2.ResourceCompiler$CompileTask.call(ResourceCompiler.java:125)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListe
nableFutureTask.java:125)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
INFO: Elapsed time: 335.194s, Critical Path: 145.75s
INFO: 1568 processes: 74 internal, 1308 local, 186 worker.
FAILED: Build did NOT complete successfully
The referenced file: bazel-out\android-armeabi-v7a-fastbuild\bin\external\maven_android_everything\_aar\unzipped\resources\com_google_android_material_mat erial\res\animator\mtrl_extended_fab_change_size_collapse_motion_spec.xml does exist under the bazel-out directory of my project, but after the build failure, the temp directory C:\Users\bdlei\AppData\Local\Temp\android_resources_tmp3839340977225638696 does not exist. I had an explorer window open to my AppData\Local\Temp directory last time I tried building and many such android_resources_temp... came and went during the build (which I expected). I removed older ones before trying the build again and while I wasn't able to track if the one named in the error ever existed, it does not exist afterwards (exactly one of these was left after the build failure).
The behavior is consistent: the original project consistently succeeds and the branched out fails. This persists through bazel clean, bazel sync, and bazel shutdown calls.
Both projects are depending on android via a call into a 3rd "dependencies" project that creates a maven repo and builds a repo out of that:
def android():
if 'maven_android_everything' not in native.existing_rules():
maven_install(
name = "maven_android_everything",
artifacts = [
"androidx.activity:activity:1.2.3", # using 1.4.0 causes indexing issues in dex without force-jumbo, even without dagger-views.
"androidx.appcompat:appcompat:1.3.1",
"androidx.appcompat:appcompat-resources:1.3.1",
"androidx.constraintlayout:constraintlayout:2.1.1",
"androidx.core:core:1.7.0",
"androidx.fragment:fragment:1.3.6",
"androidx.lifecycle:lifecycle-viewmodel:2.3.1",
"androidx.viewpager2:viewpager2:1.0.0",
"androidx.recyclerview:recyclerview:1.0.0",
"androidx.tracing:tracing:1.0.0",
"com.google.android.material:material:1.4.0",
],
excluded_artifacts = [
maven.exclusion(
group = "com.google.guava",
artifact = "guava",
),
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2/",
],
)
new_simple_repo( # Simple custom repo rule to make an #android repo for use elsewhere
name = "android",
build_file_content = """
package(default_visibility = ["//visibility:public"])
android_library(
name = "android",
exports = [
"#guava//:concurrent",
"#maven_android_everything//:androidx_activity_activity",
"#maven_android_everything//:androidx_appcompat_appcompat",
"#maven_android_everything//:androidx_appcompat_appcompat_resources",
"#maven_android_everything//:androidx_constraintlayout_constraintlayout",
"#maven_android_everything//:androidx_core_core",
"#maven_android_everything//:androidx_fragment_fragment",
"#maven_android_everything//:androidx_lifecycle_lifecycle_viewmodel",
"#maven_android_everything//:androidx_viewpager2_viewpager2",
"#maven_android_everything//:androidx_recyclerview_recyclerview",
"#maven_android_everything//:com_google_android_material_material",
],
)
""")
I've tried bumping versions to see if maybe that might help, but after slogging through dependency conflicts and finally getting bazel sync to succeed, I hit this bug.
I'm trying to pare my "playgroung" project down and see if I can isolate anything, but even removing a dependency on the original project doesn't help.
I had some time to come back to this today and after much experimenting, including trying to set up a minimal example to use when filing a bug with bazel, I believe I found the problem. It appears to relate to the lengths of resulting file names. By trying various lengths of the name of the maven repo used in the maven_install command, I was able to get the build to fail or pass consistently based on the length. Any name 21 characters or shorter and the build succeeded, while any name longer than 21 characters would result in the file-not-found error.

TypeError: undefined is not an object (evaluating 'argv.indexOf')

I'm running a React Native app which has a local Node project as a dependency, managed through yalc. I'm using rn-nodeify to deal with the Node libraries.
Whenever I try using one of the methods/constants from my Node project, I get the above error during react-native start after the app is built (I'm using Intellij's default "Android" configuration to run RN and have an emulator in Android Studio).
I looked up the error message and people say it's related to supports-color, but neither of my projects use that library and installing it didn't fix it either.
Edit:
I'm not sure if this could be related, but I also have to add the lines
import { Buffer } from 'buffer';
import 'reflect-metadata';
global.Buffer = global.Buffer || Buffer
When I use this file from my Node project or I get errors regarding Reflect.hasOwnMetadata and Buffer

Kotlin Debugging doesn't start in visual studio code

I'm new to Kotlin programming language. so... i have downloaded a few extensions such as Kotlin, Kotlin language,Kotlin Formatter, and when i press F5 it gives an ERROR...just one important question which is, should i use another IDE like intellij ?? because i don't really wan't to spend my time on fixing problems, also my computer can't handle android studio so it's between intellij and Vscode.
Error in the link below:
fun main(args: Array<String>) {
println("Hello World!")
}
that's the image of what i tried to debug + ERROR
I also had a hard time with setting up the debugger, and what worked for me was to checkout a template repository from https://github.com/fwcd/kotlin-quick-start and add the following debug configuration (.vscode/launch.json):
{
"version": "0.2.0",
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}",
"mainClass": "quick.start.AppKt"
}
]
}
As a bonus, Gradle is set up then, and one can build, run, and test the app out of the box.
Prerequisites
In VS Code I have installed the following plugins:
https://marketplace.visualstudio.com/items?itemName=fwcd.kotlin
https://marketplace.visualstudio.com/itemsitemName=mathiasfrohlich.Kotlin
https://marketplace.visualstudio.com/items?itemName=naco-siren.gradle-language
And I have installed the following packages locally:
snap install openjdk
snap install --classic kotlin
Of course you can debug your Kotlin code in Visual Studio Code. No need for IntelliJ or Android Studio.
To enable debugging in VS Code, you should install the Code Runner extension
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
and should have the Kotlin command-line compiler installed and configured in your system as well:
https://kotlinlang.org/docs/command-line.html
See the pages below for further, detailed infos:
https://formulahendry.wordpress.com/2017/05/21/code-runner-supports-kotlin-in-visual-studio-code-now/
https://dev.to/mwrpwr/learning-kotlin-programming-with-visual-studio-code-5e29
https://medium.com/#agavatar/programming-with-kotlin-in-visual-studio-code-1d745d6b4ad1
Yes. You can proceed with intellJ. There is first priority i.e. Android Studio but as you mentioned it can not be handled, so you can use IntelliJ.
The advantage of Intelli J it provide by default support files and libraries for Kotlin Development so you don't need to install external extension.
he Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
For more info please visit official website
https://www.jetbrains.com/idea/features/

How to use sbt-android to build scala android projects with RenderScript files?

It seems that sbt-android is ignoring the presence of the RenderScript files and is not generating the ScriptC_xxx java classes that are normally generated by gradle builds/Android Studio [UPDATE: this is false, se the update note below]. Because of this issue, the sbt-android build is failing because to use the scripts we need to reference the generated ScriptC_xxx classes, which gives the following error when building:
[error] apackage/YYYClass.java:55: cannot find symbol
[error] symbol: class ScriptC_xxx
[error] location: class apackage.YYYClass
[error] ScriptC_xxx xxxScript = new ScriptC_xxx(rs);
The generated .sbt file from the existing project (which compiles normally by gradle) has the apparent necessary configuration for RenderScript, generated from the build.gradle file:
rsTargetApi in Android := "18",
rsSupportMode in Android := rsSupportMode.value || true
What I am missing to be able to compile renderscript-containing android projects with sbt-android ?
UPDATE: I realized that the java classes for the scripts are being generated correctly, but somehow the classes that use those generated classes cannot find them, so maybe I have a classpath configuration problem.
This is the current file structure:
./asubmodule/src/main/rs/xxx.rs
(using package declaration #pragma rs java_package_name(apackage.scripts))
./asubmodle/src/main/java/apackage/YYYClass.java
./asubmodule/target/android/generated/source/android/support/v7/appcompat/R.java
./asubmodule/target/android/generated/source/apackage/scripts/ScriptC_xxx.java
Unfortunately, it seems com.android.builder.core.AndroidBuilder no longer generates .d files for processed renderscript sources. Bypassing AndroidBuilder to use com.android.sdklib.build.RenderScriptProcessor in sbt-android could restore the .d files that are required to determine the generated files. But that would be a solution for a future version of sbt-android.
To work around your problem for now, you can add the following into your build.sbt:
sourceGenerators in Compile += Def.task {
implicit output = outputLayout.value
val layout = projectLayout.value
(layout.generatedSrc ** "ScriptC_*.java").get ++ (layout.generatedSrc ** "*BitCode.java").get
}.taskValue
Since it sounds like you're using sbt-android-gradle you can just create a new file build.sbt and throw the above in (do not edit the 00-gradle-generated.sbt)
Update: this will be fixed in the next version of sbt-android https://github.com/scala-android/sbt-android/commit/ec09a55233aabd50e7df0085b10c567e38b616d3

Use custom system service in app (Android Studio)

First of all, thank you for your help.
Here is my problem.
I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
I am now ready to test the functionality using an app. I am using the following code:
import android.os.BacklightManager; //My service manager name
...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...
if(!bm.isBacklightOn()) {
//Turn it on.
} else {
//Other Things...
}
My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)
It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio

Categories

Resources