testDefaultGrantsWithRemoteExceptions in Xamarin.Android - c#

Recently I have implemented firebase in my Xamarin Android project.
After that it is working successfully in Debug mode,but when i go to release mode,
application is getting installed but crashes on opening.
I saw the Device log,saw some error saying-
testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager$NameNotFoundException: com.google.android.permission.gts
I am not sure whether it is related to firebase or something else.
Just visited the link-
https://sunj.iteye.com/blog/2387714
How can i do this in Xamarin.Android where this method can be implemented,
also how will it effect application.
Also is there any way to see the reason why application is crashing,there is no error ,no exception.In output window also nothing weird showing,but still crashes in Release mode.
Thanks,

Related

Xamarin.Android.Common.Debugging.targets(604,5): error XA0010: No available device

Whenever I try to start the HelloMaui project from VS Code using NET 6.0.100 Preview4 with mono debug extension installed and run it it throws an error Xamarin.Android.Common.Debugging.targets(604,5): error XA0010: No available device. I wonder if anyone had a problem running the sample project?
The same bug has been reported 3 days ago in the official repo https://github.com/dotnet/maui/issues/1197, as MAUI still in an early stage it better to follow on the official repo.
Try to ensure that the emulator is ready before debugging the app (build+deploy), by starting it manually.
Not sure how to do it from vs code but probably will be common for command line:
Navigate to C:\*\Android\android-sdk\emulator
emulator -list-avds
You should see at least one emulator name otherwise you need to install one.
emulator.exe -avd NameOfYourEmulator -partition-size 512 NameOfYourEmulator taken from the previous step.
Docs
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/command-line-emulator
Edit
If the returned list of Android device emulators is empty (from step 2) and you are sure you have at least one emulator previously added/installed then try unloading and reloading the android project.
If you are not sure, you may open Android device manager from visual studio and check the listed devices there, if empty then you need to add at least one.
Related issue Maui-check fails on Android Emulator Setup

Unity error with Firebase RealTime Database

I have been using Unity for a year now and have decided to make a simple chat app. I decided to use Google's Firebase to store my user and chat data. I plan to have the app on android(iOS in the future). My problem is with Unity not being able to generate a Firebase Android File. I searched the error up and it took me to this website. I did the recommend solution and created the realtime database and re installed the json and plist files. It did not work. I still get the following error.
Generation of the Firebase Android resource file google-services.xml from /Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Firebase Data/google-services.json failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
"python" "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Library/PackageCache/com.google.firebase.app#7.2.0/Firebase/Editor/generate_xml_from_google_services_json.py" -i "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Firebase Data/google-services.json" -o "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Plugins/Android/FirebaseApp.androidlib/res/values/google-services.xml" -p "com.maranstudios.stemastery.maran" ...
I also checked the external tools. Under android it says JDK installed with Unity, Android SDK tools installed with Unity, Android NDK Installed with Unity and Gradle Installed with Unity. I also donwloaded the android studio so I can build to android.
I have also tried to restarted unity, visual studio and even my computer, but that did not help.
Unity runs the program perfectly well on my iMac and can access my RealTime Database in the unity editor. But when I run it on my phone 2 errors pop up.
DllNotFound Exception: Firebase CppApp ...
It can not find the default reference.
2's Explanation:
I have this line of code.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
I then check in another script if t hat is null. It becomes null on my phone, but works fine on my mac.
I am using macOS Mojave (Version 10.14.4).
My unity version is Unity 2020.3.4f1.
My phone uses android 10.
I have tried everything that I can think of to deal with this error. I believe that by fixing this error, my app will work properly on my phone. I have tried to give all the information needed to help you understand my issues. If I am still missing any, please ask and I will respond as soon as possible.
EDIT :
I tried a couple new things. I upgraded to unity 2020.7, but that did not work. I also tried to create a new project from scratch using Unity 2019, but I am still getting that same error. Could it be that Firebase just doesn't work on my mac or is that this a bug in Unity that has somehow existed over several versions? I really could use some help figuring out to integrate Firebase. Any help is appreciated.
This is a known issue with developers who have non-ascii usernames. See this issue and this issue. It might be worth opening a new issue and highlighting that it's blocking active development right now (note for future readers, the first issue is closed but the second is open as I write. If 690 is also closed with a milestone associated, this means that the issue has been fixed).
For potential workarounds, the best known workaround would be to use a username without any extended non-ascii characters. I know that this can be problematic or disruptive.
You may try disabling persistence in the Editor before making any database calls. This might prevent Firebase from trying to read your local data folder, avoiding the issue:
var database = FirebaseDatabase.DefaultInstance;
if (Application.isEditor) {
database.SetPersistenceEnabled(false);
}
var reference = database.RootReference;
You only have to do this once for your game (so maybe immediately after CheckAndFixDependenciesAsync), but putting it right before database access should makes my example code safer.

Uwp app crash immediately after compiled with .net native toolchain

I'm creating an uwp app. My app works well in debug mode. But when compiled with .net native toolchain, which is essential to publish app to the Store, it crash immediately. I was trying to enable all the exception settings but it didn't hit any breakpoints. All the information I can get from the output is:
The program '[9548] DemoBuildError.exe' has exited with code
-1073741511 (0xc0000139) 'Entry Point Not Found'. Activation of the Windows Store app
'9e380736-23cf-476f-b625-be7baa70ad56_jatac5brr3jea!App' failed with
error 'The app didn't start'.
I also try to create new project and copy, paste carefully as mentioned in some previous threads but no luck.
Here is my demo project to reproduce the error: https://bitbucket.org/wpdev01/demobuilderror
Any ideas?
Since your repo is private, I'm also facing the same problem, I guess it's due to some third party controls your refered.
In my project, I unloaded all third party controls, it works fine again.
in your case its quite a problem.
try to add "unhandledexception" :https://learn.microsoft.com/en-us/dotnet/api/system.appdomain.unhandledexception?view=netframework-4.8
debug and see what's next.
in debug mode compiler optimizations are turned off but the app is should work the same.

Android app debugs for a few seconds then just stops

I'm trying to set up a new Android app development environment at home and I've run into a problem that is a showstopper.
First, here is my environment:
Windows 10
Visual Studio Community 2015 with Xamarin platform installed
Test device is: G Pad 7.0 LTE
Android Version 5.0.2
I'm following this tutorial: MSDN tutorial
When I go to debug my test app, here is what happens.
Select debug from Visual Studio with my tablet as the target
VS deploys to the tablet
App starts on the tablet
App and debug session runs for about 5-10 seconds.
Debug session ends and app closes
No errors are displayed in Visual Studio and when i turn on Android logging it's a such a massive overflow of information that I don't really know where to begin searching for a problem.
Please also note that when I first set up the app, according to the tutorial, debugging on the tablet worked fine. The initial build is simply a template with a few basic controls.
In between then and when it stopped working I also added and successfully tested a Windows Phone project on a Windows Phone device.
Once I got to the section where I was modifying the project is when the problem started. I thought that perhaps a change in the code I did caused this issue so I tried another blank app and that blank app now crashes as well.
When I deploy the tutorial app to an emulator it crashes immediately but when I deploy a blank app it doesn't crash.
I also tried restoring the tablet to factory defaults and testing again. Same scenario: Blank app and tutorial app run for a few seconds, debugging stops, app closes.
Any clue as to what type of problem I'm looking at?
Solution
Clean your project (Right-Click on Project and select clean)
Go to your build folder. Probably in your Android project's root folder, named "obj". Delete either build you had, when you ran into this behavior (Debug or Release).
Directory Path
./AndroidProject/obj/Debug
./AndroidProject/obj/Release
Restart Visual Studio
Build and run again and it should work just fine, as the md5-hashes are now matching again.
I had also uninstalled the app before from the device and restarted it, I don't know whether this is required anymore, because the app is now being "reinstalled" by newer Xamarin versions anyway.
adb uninstall com.your.domain
Story and Background information
Have had the same issue with a device running Android 5.0.
Basically, the app was just stopping without any note.
When I now restarted the phone, The log was extended (once) by the following line:
Device could not find component named: *com.your.domain*/{*md5hash*}.*{Activity}
It turns out that with Andrpod 5.0 a hashing mechanism was implemented:
With the 5.0 release, the default package names for Android Callable
Wrappers will be based on the MD5SUM of the assembly-qualified name of
the type being exported. This allows the same fully-qualified name to
be provided from two different assemblies and not get a packaging
error.
See this for further information Xamarin.Android 5.1
So, if the md5-hash now changes from time to time, a simple Clean of your project is not enough.
I ran into this same issue and applied the same solution described above many times, which seemed to remedy this particular problem.
A possibly related fix, but definitely worthwhile note
After releasing this Android app and later releasing updates to the app, we got feedback from users that their Android Home screen shortcut to the app was disappearing after each app update. This is not good, for obvious reasons, but the fix for it was very simple as noted here:
dream-team-mobile-blog - Android app removes shortcut on update Xamarin solution
On the main activity, set a Name attribute of
<your package>.<your main activity>
like:
com.mycompany.myapp.MainActivity
For my solution, I chose to do it in code like this:
[Activity(Name = Constants.PackageName + "." + nameof(MainActivity),
Label = Constants.AppIconTitle, Icon = "#drawable/icon",
Theme = "#style/splashscreen", MainLauncher = true,
LaunchMode = LaunchMode.SingleInstance,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
//Side Note: I change my PackageName between Prod and SQA builds, so using
//a constant as seen above makes that change less risky to miss maintaining.
//Also, using nameof() keeps things tight and a sure match.
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
I mention it here in this post because, having this fix in place may have:
definitely prevented app shortcut loss and
possibly prevented the issue discussed in this post
as the MD5 hash prefix from the Main activity seems to no longer be generated.
This tweak may fix two bugs with one fix. If not, implementing a fixed main Activity Name will surely help your users keep their shortcut to your app when you release updates!
What fixed it for me in Visual Studio 2017 is going to :
Tools → Options → Xamarin → Android Settings
and uncheck:
Preserve Application data cache on device between deploys
go to your AndroidManifest.xml and change your package name.

Windows 8 Store - Debug App Downloaded from store

Is there a way to debug a Windows Store app downloaded from the store? I have the source code from the build I uploaded, but no breakpoints are working.
The reason I ask is that in-app purchases aren't working in the live store, but they work fine in test mode. I need to see the exception being thrown--which is caught by the app and printed to Debug.WriteLine, but I don't see it in the console either.
Ok, it works if you follow these steps:
Debug->Debug Installed App Package
Make sure that "Debug this code type:" says "Mixed (Managed and Native)"
Once I checked that box, it worked fine, but of course debugging was pretty slow.
PS - You also have to include the symbol files in the original build uploaded to the store. This is a good reason to always do this.

Categories