I keep getting this error. (I'm using Android v8.1 and Prism default template)
Severity Code Description Project File Line Suppression State
Error Your project is not referencing the "MonoAndroid,Version=v8.1"
framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks"
section of your project.json, and then re-run NuGet restore.d#
PrismHelloWorld.Android
So I went into my project.assets.json and change the "monoandroid71" to "monoandroid81"
"originalTargetFrameworks": [
"monoandroid71"
...
"monoandroid71": {
"projectReferences": {
...
"frameworks": {
"monoandroid71": {
I also changed
"projectFileDependencyGroups": {
"MonoAndroid,Version=v7.1": [
and ...
"targets": {
"MonoAndroid,Version=v7.1": {
I hit save and rebuild and it works absolutely fine! The problem is something is editing the json file and turning it all back to 71 and 7.1. I am not sure what is doing it but I will hit built and see the error again, about me needing a reference to v8.1.
Has anyone encountered this issue before?
Go to Android project Options -> Application -> Compile using Android version: (Target framework) and choose Android 8.1 (Oreo). Try different options
I just had the same problem on MvvmCross with Xamarin and I did your solution (changing "monoandroid71" to "monoandroid81" and "v7.1" to "v8.1") but it reverts back after closing and reopening the solution. What I did was do the same thing and do a "Restore NuGet Packages" at the end.
got the same issue, and able to fix it using below option,
Change the target version and rebuild.
I had the same issue, what I did was just restarted VS, and its back to normal
I resolved it by:
Right click Android project => Properties => Application => Compile using Android version => Android 7.1
Clean and Build project => build success, and restart IDE.
Right click Android project => Properties => Application => Compile using Android version => Android 8.1
Clean and Build project => build success
File obj/project.assets.json updated to "MonoAndroid,Version=v8.1"
Related
I have been working on a MAUI android application and when debugging, the breakpoints is not hitting and the application enter in a break state. But for windows app it works well.
I think this is an issue with the .NET 6 Android Tooling in visual studio 2022. Is there any solutions for this problem ?
Here is a few steps I did to make things work with debugging MAUI Android apps. I was able to debug and get my regular exceptions and hit breakpoints after this.
Add this code to Android platform main activity OnCreate method
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Then this hander method in the same class
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ System.Diagnostics.Debug.WriteLine(e.ToString());}
Reset Your Exceptions for CLR. Shortcut is (Ctrl+Alt+E).
Just double-click on the CLR Exceptions checkbox to reset.
Disable Debug Your Code Only in Options
I was also having problems debugging some projects. (Preview 17.1.0) The ones that were failing had the following project settings.
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks> ...
Moving Android first fixed my problem
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> ...
I had the same problem and it is now working, try this:
Windows -> Settings -> Update & Security -> For Developers -> Developer Mode - On
Solution Properties -> Deploy - On
Visual Studio -> Tools -> Options -> Xml Hot Reaload -> Disable all
The you can just set your project has startup and run it.
Unity has a default gradle.properties file that gets added during the build process. While its possible to change the build.gradle and the settings.gradle files as mentioned
here https://docs.unity3d.com/Manual/android-gradle-overview.html
there is no mention of being able to change gradle.properties within the unity docs. The file also gets recreated every build attempt so editing it within the temp/gradleOut after a build and building again doesn't work. I know exporting the project is possible as well, but I'm looking for a solution where the project can be run directly from unity.
Btw this question is NOT a duplicate of this question How to use Gradle in Unity
The answer here has nothing to do with modifying the gradle.properties file.
This is a duplicate of this question that got incorrectly marked as a duplicate how to change default gradle.properties of Unity?
Maybe my answer is a bit outdated but in Unity 2020 you can do it in:
Player Settings -> Tab Android (with robot obviously) -> Publishing Settings -> Custom Gradle Properties Template (checkbox).
After enabling the checkbox you will see the path to gradleTemplate.properties (usually it appears in Assets/Plugins/Android directory) file which will be merged with final gradle.properties.
Everything you need you can write to the end of file after **ADDITIONAL_PROPERTIES** string.
Example:
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
**ADDITIONAL_PROPERTIES**
android.useAndroidX = true // I added this property to fix error: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
Also on screenshot:
This was something that was slightly hard to discover. I was going to do a regular post build processor like I had for my iOS build, but as I was searching for a manner to load and determine where the properties file was, I ran across the following interface in the documentation : IPostGenerateGradleAndroidProject.
According to the documentation:
Implement this interface to receive a callback after the Android
Gradle project is generated.
So below is my initial brute force implementation for turning on androidX and jetifier.
public class AndroidPostBuildProcessor : IPostGenerateGradleAndroidProject
{
public int callbackOrder
{
get
{
return 999;
}
}
void IPostGenerateGradleAndroidProject.OnPostGenerateGradleAndroidProject(string path)
{
Debug.Log("Bulid path : " + path);
string gradlePropertiesFile = path + "/gradle.properties";
if (File.Exists(gradlePropertiesFile))
{
File.Delete(gradlePropertiesFile);
}
StreamWriter writer = File.CreateText(gradlePropertiesFile);
writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
writer.WriteLine("android.useAndroidX=true");
writer.WriteLine("android.enableJetifier=true");
writer.Flush();
writer.Close();
}
}
Theoretically you should be able to manipulate the generated gradle project in any manner to your choosing during the post build processor. Some additional tools might be helpful, like the PBXProject support on iOS, but until then, this will do.
IPostGenerateGradleAndroidProject is a new Interface added after Unity2018.
As my project based on Unity2017, it's not a good solution. Then I found this. A solution with Gradle.
([rootProject] + (rootProject.subprojects as List)).each {
ext {
it.setProperty("android.useAndroidX", true)
it.setProperty("android.enableJetifier", true)
}
}
Although this is not a perfect solution, you can use the "Export Project" option.
Build Settings
After exporting the project, you can modify gradle.properties and build using AndroidStudio or command line.
In the newer Unity versions (2019.4+) it is possible to generate a custom gradle properties template by going to Project Settings > Player > (Android Tab) > Other Settings > and marking "Custom Gradle Properties Template".
After selecting that a gradleTemplate.properties file is generated at "Assets/Plugins/Android/gradleTemplate.properties".
This is the best way of generating the file since it is git friendly and preserves other settings.
I have created a simple universal app targeting Windows Phone 8.1 & Windows 8.1 in Visual Studio 2013.
I added an android project and implemented MvvmLight.
ViewmodelLocator, viewmodels & messaging all work fine.
Databinding also works for the windows projects.
When I try adding databinding within the android project - at run time I get an error Property not found: Text
Button bindingButton = FindViewById<Button>(Resource.Id.button1);
var vm = ViewModelLocator.Main;
this.AddBinding(() => vm.AsyncCompleted,
() => bindingButton.Text,
BindingMode.TwoWay);
Has anyone else encountered this?
OK - solved it myself.
I was originally following an example from the mvvm light home page which doesn't seem to work with an Android project within a Universal App.
The answer is to specify the Actual control to add the binding to and pass the fully qualified View Model property to the binding:
Button bindingButton = FindViewById<Button>(Resource.Id.button1);
bindingButton.AddBinding(
() => ViewModelLocator.Main.AsyncCompleted,
() => bindingButton.Text,
BindingMode.OneWay);
Recently the gradle plugin for android got updated (with android studio), after which the previous way of getting to the SDK directory ceased to work. The expression
${android.plugin.sdkDirectory}
which worked in an older version now returns the error
Error:(42, 0) No such property: sdkDirectory for class: com.android.build.gradle.LibraryPlugin
What would be the proper way of getting the android SDK directory being used, preferably independent of the user's configuration such as plugin and gradle version? The script needs to be shareable with several users.
Since all the previous answers depend on the environment or specific user intervention on top of normal configuration, I'll just post my technically messy fix.
if (android.hasProperty('plugin')) {
if (android.plugin.hasProperty('sdkHandler')) {
androidPath = android.plugin.sdkHandler.sdkFolder
} else {
androidPath = android.plugin.sdkDirectory
}
} else {
androidPath = android.sdkDirectory
}
Unlike all previous methods, this actually works, but it still looks hacky.
In gradle.properties set location sdkdir=/home/user/android-sdk and then in gradle you can use $sdkdir
I'm using Android gradle plugin v1.2.3 and this works fine:
${android.sdkDirectory}
You can use
$System.env.ANDROID_HOME
export ANDROID_HOME=/xxx/xxx/ in shell, then use it by System.env.ANDROID_HOME in gradle file.
Has anyone successfully worked with BlueCove in Android?
I've tried to add bluecove.jar in my project but i get the message: The library 'bluecove-2.1.0.jar' contains native libraries that will not run on the device.
Has anyone had and solved this issue?
Follow this link:
http://groups.google.com/group/bluecove-developers/msg/847f714034b34126
and in [ Window -> Preference -> Android -> Build ] unckeck first two voices:
1) Automatically refresch resource....
2) Force error.....
I solved in this way