Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

System.IO.FileNotFoundException: Could not find file “/data/user/0/com.abshar.app/files/xxxx.json

judsonabrahamjudsonabraham USMember ✭✭✭

I'm trying to use google translate api. So I downloaded the service account json file from google cloud. And I put the json file in Files folder in my Android project. I have used numerous codes but I'm not able to access the json file. I'm getting this exception

System.IO.FileNotFoundException: Could not find file "/data/user/0/com.abshar.app/files/xxx-280817-bedb566bfd11.json" at System.IO.FileStream

This is my code in xaml.cs

string jsonpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),"xxxx-280817-bedb566bfd11.json");
                System.IO.File.OpenRead(jsonpath);
                System.IO.File.ReadAllText(jsonpath);
                System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS",jsonpath);

                TranslationClient client = TranslationClient.Create();

I dont have any clue how to fix this. Any suggestions?

Answers

  • lukeid123lukeid123 Member ✭✭

    Are you adding it through Android Device Monitor - under data/data/com.XXX.XXX/files

    You may need to 'adb root' command in an Android Adb Command Prompt to access the folder

Sign In or Register to comment.