Can't find R.java in Android Studio 3.6(newest release) - android-studio-3.6

When I use Android Studio 3.5, I've known where R.java is.
But in Android Studio 3.6, the newest version, the location of R.java is changed.
Where is it? Thanks.

The change is in android gradle plugin 3.6, from the official android site:
Additionally, Android Gradle plugin has made significant performance
improvement for annotation processing/KAPT for large projects. This is
caused by AGP now generating R class bytecode directly, instead of
.java files.
android studio 3.6

Related

XA5104 Could not locate the Android NDK

XA5104: Could not locate the Android NDK. Please make sure the Android NDK is installed in the Android SDK Manager, or if using a custom NDK path, please ensure the $(AndroidNdkDirectory) MSBuild property is set to the custom path.
The NDK location is set to the ndk within the android sdk but still this shows up
All the answers above are valid.
But in case you can't change the default location of the Android NDK through the settings (it was my case, I think it's a Windows 11 problem as surprising as it may sound):
Make sure you installed NDK, if not:
Tools > Android > Android SDK manager > Tools > select NDK > Apply Changes
Create a folder named "AndroidNDK64" in C:\ProgramData\Microsoft
Move the C:\Microsoft\AndroidNDK\android-ndk-... folder to the folder you just created
It worked for me and I hope it works for you too 😉
I came across this issue and it turned out to have nothing to do with the Android NDK. I was trying to deploy a debug version of my app on top of a release build, changing back to debug or uninstalling my app solved the problem.
happens to me after updating VS 2019 to Version 16.11.5 two days ago,
it happens before AND after I install ndk from Android SDK Manager,
and Android NDK Location setting is NOT in VS Options->Xamarin->Android Setting, check this FAQ https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/android-sdk-location?tabs=windows
I had same issue just reverted to version 21.4.702 and everyting started to work
Had the same issue on Visual Studio for Mac. Downgrading to 21.4.7075529 allowed the Android project to build and deploy.
I was getting this error after changing to a Release build and trying to deploy. I tried the other answers and made sure the app was not present on the device. Nothing worked.
What did work, was opening the Android SDK manager and uninstalling the NDK and then re-installing.
After that, I was able to deploy the Release config of the app with no problem.
This was VS2019 for Windows 10.
I had the same issue and fixed it by adding the NDK manually. Please follow the steps down below.
Make sure that you have already installed NDK from Visual Studio's Android SDK Manager window.
Copy "ndk-bundle" folder from "C:\Program Files (x86)\Android\android-sdk"
Paste it under the "C:\ProgramData\Microsoft\AndroidNDK64" path.
Rename the pasted "ndk-bundle" folder to "android-ndk-r21"
Finally, run the project and enjoy.
just toasted this problem and suggestions here either outdated or makes less sense. You dont need to separately install NDK, VS22 is deliviring it together with SDK installation. So there is a folder called NDKbundle under the SDK folder. Only problem here is that you need to make sure that you have the correct NDK. You cannot use latest version of NDK if you arent using everything up to date and if you comply with the NDK criterias. Here you can find the history
https://developer.android.com/ndk/downloads/revision_history
For example, if you are NDK23 you cannot use if you target APIs 16, 17, and 18 as it is stated in the release notes "Jelly Bean (APIs 16, 17, and 18) will not be supported in the next NDK release. ".
For me was the case, I had recently VS22 repair and somehow, SDK installed the latest version of NDK and i was getting this error. Once i downgraded back to NDK21 version, it worked like a charm.

Xamarin - How to update Mono.Android version to resolve dependencies?

I'm trying to install a nuget package (Xamarin.Firebase.Firestore) which requires a newer version of Xamarin.GooglePlayServices.Basement (60.1142.0, I have 42.1021.1), which in turn requires me to update the xamarin.android.support packages. When I try to update those, I get this error
"Package Xamarin.Android.Support.Design 27.0.2 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1)"
I've tried changing my target android version to 8.1, I've also updated my SDK as well as the build tools. I'm running Visual Studio 15.6.1. As a last ditch effort, I tried deleting the Mono.Android V8.0 reference and then adding a new reference to V8.1, but whenever I do so, Visual studio just ends up adding the reference with the path pointing to V8.0, even though the reference I added was clearly pointing to V8.1.
Anyone has a clue how to resolve this issue?
tried changing my target android version to 8.1
You need to change the Target Framework that is used to compile your android application, not the Target Android version (but assumably you would set these two to the same, read the Understanding Android API Levels link below.
Visual Studio for Windows:
Visual Studio for Mac:
Target Framework – Specifies which framework to use in building your application. This API level is used at compile time by Xamarin.Android.
Minimum Android Version – Specifies the oldest Android version that you want your app to support. This API level is used at run time by Android.
Target Android Version – Specifies the version of Android that your app is intended to run on. This API level is used at run time by Android.
Understanding Android API Levels
Manifest Entries:
Visual Studio for Windows:
Visual Studio for Mac:

Using EF7 SQLite on Android 7+

In my project, I am using the Microsoft.EntityFrameworkCore.SQLite package from NuGet. But for Android 7+, the app crashes with unauthorized access to "/system/lib64/libsqlite.so".
This is because Android 7 doesn't allow native libraries other than the ones in their NDK (as far as I understood). Also see this issue: https://github.com/aspnet/EntityFramework/issues/7777.
So, I researched the internet for about 2 days now and unsuccessfully tried a bunch of things to get EFCore to work on Android 7. One of them was to update to the preview version v2.0.0-preview1-final. But this resulted in other problems like the following where the app compiled, but crashed while deploying/starting on the emulator:
06-21 09:58:18.970 D/Mono ( 3632): Assembly Loader probing location: 'System.Runtime.CompilerServices.Unsafe'.
06-21 09:58:18.970 F/monodroid-assembly( 3632): Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
06-21 09:58:18.970 F/monodroid-assembly( 3632): This might be due to an invalid debug installation.
I then tried to add the 'System.Runtime.CompilerServices.Unsafe' NuGet package manually to my project, but it didnt fix the problem.
I messed around a lot, trying different build parameters and such and actually got the app running with the preview package of EFCore on an Android 7 emulator. However, after a project clean and rebuild, the error showed up again.
Any help on how to get EFCore Sqlite to work on Android 7?
I am using Visual Studio 2017 with Xamarin.Android 7.3.1.2
I created an example project in order to reproduce the issue: https://github.com/tipa/EFCoreSample - Basically just started with the basic Android template from VS and added the Nuget package
I know this was asked more than two months ago and you've probably found the solution, but I've wanted to post how we've managed to get around this issue.
We are developing a Xamarin.Forms application with EntityFrameworkCore and SQLite. Due to project and company policies, we are restricted to using .NetStandard 1.6 (we migrated our PCL projects from .NetFramework to .NetStandard in order to integrate EntityFrameworkCore).
After this issue started happening to us, we managed to fix this by doing the following:
Updating "Microsoft.EntityFrameworkCore" and "Microsoft.EntityFrameworkCore.SQLite" from version "1.1.1" to "2.0.0-preview1-final" (this is the latest version that works with .NetStandard 1.6) in the DAL project (we have a separate PCL project that contains the Context, UoW, Repositories and Models)
Updating just "Microsoft.Data.Sqlite" (this automatically updates the needed dependencies) from version "1.1.1" to "2.0.0-preview1-final" in the main Xamarin.Forms Android project
EntityFrameworkCore versions 2.x.x use the Android 7+ "approved" way of accessing the "libsqlite.so" file, while versions 1.x.x do not.
Hope this is of help to anyone who might use similar packages that we had.
I had the same issue and I found a solution to this problem.
I'm using Xamarin.Forms applications with .Net Standard 2.0 libs and using EFCore with SQLite. All you have to do is edit your Android csproj and add this after the last PropertyGroup tag:
<PropertyGroup>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
And then add the reference for System.Runtime.CompilerServices.Unsafe in csproj:
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.3.0" />
Clean and Rebuild your Android Project.
I found the answer to the problem here: https://developercommunity.visualstudio.com/content/problem/152947/xamarin-android-run-error-could-not-load-assembly.html

Android Studio - Gradle Failure - Intel Atom x86

I need your help please,
I imported an old Project in my Android Studio. I solved actually many problems, but now there is a problem i can´s solve. My Android Studio says:
(Failed to sync Gradle project 'ChatSecureAndroid')
Error:Cause: failed to find target with hash string 'Intel Corporation:Intel Atom x86 System Image:10' in: C:\Android\sdk
Open Android SDK Manager
I allready Installed all points in Android SDK Manager (API 10).
My target SDK version is 21 - i also Installed all points in Android SDK Manager (API 21)
Someone know any way i can try? :/
Greetings and Thanks,
felix
I think you should grep all the build.gradle files under your project tree with string "compileSdkVersion" to see if you have all the SDK platforms installed with the API level they declared.

Why would the following errors occur in Xamarin Studio on OS X but not in Visual Studio?

I'm trying to understand why I'm getting the following errors when running tests in Xamarin Studio 5.9.1 (build 3) on OS X.
System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
System.TypeLoadException : A type load exception has occurred.
All projects build successfully and the same tests run just fine in Visual Studio on Windows using the same solution.
I am seeing a warning when building the test project on OS X, despite having already installed and added the reference.
All projects referencing MyProject.fsproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
I still don't know why Xamarin behaves differently than Visual Studio, but the root cause was that the test project was targeting .Net 4.5 whereas the main project was targeting .Net 4.0
Thanks to #7sharp9 for the help.
Different platforms (Android, iOS, Desktop) have different System.Net.Http.dll binaries - compiled from the same source, but each version references the mscorlib.dll (and other base-class libraries) from the platform it was built against.
This is not a problem when you use it in an application - Xamarin Studio will automatically pick the right version for you - but you can't use it in a Portable Class Library.
Microsoft initially implemented HttpClient as part of .NET 4.5, but then released a portable version of it (with a Windows-only license). If I understand this correctly, then that's mostly the same API as in .NET 4.5 plus a few minor additions (I think they added gzip compression, which Mono's version currently doesn't).
For Xamarin / Mono, all we need to do to create an open-source version of this library is to take our existing sources and compile them against the portable profile. I haven't tried this yet, but this could be as easy as editing the .csproj file and replacing the .
Also would suggest that you install HttpClient NuGet package
System.Net.Http.HttpClient is available directly from the latest version of Xamarin.
Simply check for updates from Xamarin Studio ;-)

Resources