Visual Studio fails to compile .NET MAUI project on Android - android

When I want to build my .NET MAUI Application on Android, I get this error:
1> C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.4\tools\Xamarin.Android.Aapt2.targets(212,3): error APT2000: The specified file cannot be found. (2).
1> Processing A:\Documents\Semestre 5 Info\Recipes-MobileApp\CookUs\CookUs\obj\Release\net7.0-android\android\bin\packaged_resources JobId: 114 Exists: True JobWorked: False
1> Link did not succeed. Deleting A:\Documents\Semestre 5 Info\Recipes-MobileApp\CookUs\CookUs\obj\Release\net7.0-android\android\bin\packaged_resources
1> Done executing task "Aapt2Link" -- FAILED.
1> Done building target "_CreateBaseApkWithAapt2" in project "CookUs.csproj" -- FAILED.
1> Done executing task "CallTarget" -- FAILED.
I tried to reinstall Visual Studio a few times, to reinstall the Android SDK Components as well, but it fails everytime.
I couldn't find any informations about this.
EDIT :
As #Guangyu Bai - MSFT pointed out, the problem is caused by the path where the project is. My path contains spaces.

I found some information in the issue thread Android - APT2000 build error when project path contains non-ASCII symbols and Application cannot be deployed on Android.
The build error is caused by putting project in a folder/directory containing some non-ASCII chars, like Czech alphabet (tested with á) breaks Android build. However, this does not affect any other C# projects.

Related

Invalid File Name error when opening project stored in WSL2 file system in Android Studio

When trying to create an Android Studio project and setting its location to WSL2 file system, the error is shown:
Invalid File
Similarly when opening a project stored in WSL2 file system (example, here: \wsl$\Ubuntu\home\tyloubuntu\someproject), the error is also related to File name:
Gradle could not start your build.
> Cannot create service of type DefaultConfigurationCache using DefaultConfigurationCache constructor as there is a problem with parameter #10 of type ConfigurationCacheFingerprintController.
> Cannot create service of type ConfigurationCacheFingerprintController using ConfigurationCacheFingerprintController constructor as there is a problem with parameter #5 of type FileCollectionFingerprinterRegistry.
> Cannot create service of type FileCollectionFingerprinterRegistry using method VirtualFileSystemServices$BuildSessionServices.createFileCollectionFingerprinterRegistry() as there is a problem with parameter #1 of type List<FileCollectionFingerprinter>.
> Could not create service of type FileHasher using BuildSessionServices.createFileHasher().
> java.io.IOException: Incorrect function
or
The name of the file cannot be resolved by the system
One this is for certain, Android Studio (I am using Gradle build system) is having issues with WSL2.
Tools info:
Android Studio is installed on Windows 10.
Android Studio Version: Artic Fox Canary Beta 3
Windows 10 19042 build.
WSL2 for Ubuntu.
Gradle build system.
I tried following the same steps listed here, they worked fine with IntelliJ IDEA but giving file name errors for Android Studio: https://www.jetbrains.com/help/idea/how-to-use-wsl-development-environment-in-product.html
My use case requires storing files in WSL2. Is there a workaround or a solution for this issue?

Tensorflow Android: '#bazel_tools//tools/cpp:cc_configure.bzl' does not contain symbol 'cc_autoconf_impl'

I am testing Tensorflow Android example in Android Studio. After git clone the repository, I only edit the bazel path and WORKSPACE file to set the SDK and NDK path. When I tried to run the application, it shows the error.
Error:/home/sam/FYP/tensorflow/third_party/clang_toolchain/cc_configure_clang.bzl:3:1: file '#bazel_tools//tools/cpp:cc_configure.bzl' does not contain symbol 'cc_autoconf_impl'
Error:error loading package '': Extension file 'third_party/clang_toolchain/cc_configure_clang.bzl' has errors
Error:Execution failed for task ':buildNativeBazel'.
Process 'command '/usr/bin/bazel'' finished with non-zero exit value 1
My environment setup should not be the problem as I have successfully run the Android example for the previous version.
About two month ago I successfully built Tensorflow but with recent master branch I faced same problem.
For me, upgrading bazel(0.9.0 to 0.11.1) resolved it. My environment is macOS with brew upgrade bazel.

Unity says resource style/Theme.AppCompat.Light.NoActionBar not found

I have a Unity project which, when compiled via Unity's Gradle build option, fails with
Output: error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.xxx.sdk.unity:style/Theme.AppCompat.Light.NoActionBar) not found.
error: failed linking references.
I can reproduce this same error by entering a terminal, and going into the Temp/gradleOut directory, then saying gradle :MySDK:verifyReleaseResources or gradle :MySDK:assemble. However, if I change it to gradle :assemble then it works fine (this is what Android Studio does when I open the same Temp/gradleOut directory and it builds and runs the app fine):
/opt/Unity/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/gradle/bin/gradle :assemble
> Configure project :
> Configure project :MySDK
BUILD SUCCESSFUL in 17s
Is there a way to make Unity3d (2017.2.0f3 in my case as the latest version crashes on Linux) execute the same gradle task as Android Studio? So instead of trying to do :MySDK:whatever it would do :whatever?
Ciao,
try adding .aar files in Assets/Plugins/Android folder.
Something when you build your app for Android, look for that resource (are you using Facebook SDK for example ?) and when building android app Unity need to find that resources in android archives.
This is my configuration :

TeamCity throws FileNotFoundException trying to load android project

I setup a TeamCity server and have it successfully building several C#.NET projects. Now I'm trying to get it to build a simple Android project but cannot get it to work. Checking the BuildLog it fails with the following error:
[17:00:11][Step 1/1] Using IntelliJ IDEA External Make #141.3028
[17:00:11][Step 1/1] Loading project (2s)
[17:00:13][Step 1/1] C:\TeamCity\buildAgent\system\.jps\c67b7fe19e4788da\-1866084326\gradle\configuration.xml (The system cannot find the path specified)
[17:00:13]
[Step 1/1] java.io.FileNotFoundException: C:\TeamCity\buildAgent\system\.jps\c67b7fe19e4788da\-1866084326\gradle\configuration.xml (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:337)
at org.jetbrains.jps.gradle.model.impl.JpsGradleExtensionServiceImpl.getGradleProjectConfiguration(JpsGradleExtensionServiceImpl.java:125)
at org.jetbrains.jps.gradle.model.impl.JpsGradleExtensionServiceImpl.getGradleProjectConfiguration(JpsGradleExtensionServiceImpl.java:113)
at org.jetbrains.jps.gradle.model.impl.GradleResourcesTarget.computeRootDescriptors(GradleResourcesTarget.java:69)
...
The directory ..\-1866084326\ exists but it does not contain a gradle subdirectory.
I am not very familiar with the details of building gradle/android projects as I've only ever used AndroidStudio's UI to build. I have done a lot of searching but have found virtually no information about setting up an android project in TeamCity beyond what is in the TeamCity user docs that effectively says "use IntelliJ IDEA Build Runner".
I setup a build config with an IntelliJ IDEA Project build step. The project settings are parsed without error and I leave everything the way it was detected. The only parameters I have are Android_SDK = C:\Users\%env.USERNAME%\AppData\Local\Android\sdk, API_Level = 23, and system.path.macro.USER.HOME = %env.HOMEPATH%.
This is on a Windows 7 x64 Pro server.
I can build the project directly in TeamCity's workdir using AndroidStudio so I expect it is a build runner configuration issue, but I cannot find any search results for this specific error. Does anyone have any ideas?

Android - Phonegap - Conversion to Dalvik format failed with error 1

I installed this:
https://github.com/mwbrooks/cordova-plugin-menu
and have cordova 1.8.1 installed.
I copied "libs/phonegap-1.0.0.jar" to ANDROID_PROJECT/libs.
When i try and run the app in the simulator, i get :
"Conversion to Dalvik format failed with error 1"
I believe this is to do with conflicts with libraries, but I don't know what to do to remove the error?
please help.
I have found myself in the same situation after upgrading from 2.0.0 to 2.1.0
First of all make sure you have reconfigured the build path by removing the JAR from the old PhoneGap version and adding the new one.
At this point I started getting the Dalvik error. Cleaning the build environment didn't help.
So I remove the old jar from the libs directory and voilá, it worked.
Project -> Turn off Build Automatically. Then Build project manually and clean. Then export signed project. Problem has been gone.

Categories

Resources