Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by georgios avate · Nov 11, 2015 at 01:33 PM · androidunity 5facebookcrashinglogin

unfortunately, app has stopped when trying to log into Facebook from mobile

I managed to incorporate the Facebook API into my project successfully, meaning, my game can take screenshots and post them into Facebook when clicking a button. However, this only works when running the application within the editor; touching that same button on my android device crashes the application instead (Unfortunately, appName has stopped).

I have been looking for a solution to this issue two days now, and while I came across a lot of different fixes, nothing seems to work; I already tried generating the correct hash key (with several different approaches), the apparently famous Rafael Fix, I tried fixing the screen orientation issue via AndroidManifest.xml, and I tried commenting the ScreenShot posting code (to make sure that Login is at fault).

I haven't made the app public on facebook, or uploaded to game to the play store yet (since it isnt ready for release yet anyways), but I don't think that should cause the game to crash like this.

I have a couple of days off my mandatory army service, and I really wanted to get this up and running before I had to go back to base. But, I am at my wit's end.

I'd really appreciate it if anyone could help me out with this.

Relevant Code:

   void Awake() {
 
         FB.Init(SetInit, OnHideUnity); 
     }
 
 
     private void SetInit() {
 
         print("FB: Init");
 
         if (FB.IsLoggedIn) print("FB: logged in");
 
         else print("FB: Not logged in");
     
     }
 
 
     public void FBLogin() {
 
         FB.LogInWithPublishPermissions(new List<string>() { "email", "publish_actions" }, AuthCallback);
         
     }
 
 
     void AuthCallback(ILoginResult result) {
 
         if (FB.IsLoggedIn) {
 
             print("FB: Login success");
             StartCoroutine(TakeScreenshot());
         }
 
         else print("FB: Login failure");
       
     }
 
 
 
     public void ShareScore() {
 
         if (!FB.IsLoggedIn) FBLogin();
     }
 
     
 
     private IEnumerator TakeScreenshot() {
 
         yield return new WaitForEndOfFrame();
         //print("W : " + Screen.width + " H : " + Screen.height); 
         var width = Screen.width;
         var height = Screen.height;
         var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
 
         // Read screen contents into the texture
         tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
         tex.Apply();
         byte[] screenshot = tex.EncodeToPNG();
 
         var wwwForm = new WWWForm();
         wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
         wwwForm.AddField("message", "herp derp.  I did a thing!  Did I do this right?");
         FB.API("me/photos", HttpMethod.POST, ShareCallback, wwwForm);
     }
     
 
 
     private void ShareCallback(IResult result) {
 
         if (result == null) {
 
             print("no result");     
             return;
         }
 
         // Some platforms return the empty string instead of null.
         if (!string.IsNullOrEmpty(result.Error)) print(result.ToString());
         
         else if (result.Cancelled) print("Cancelled");
         
         else if (!string.IsNullOrEmpty(result.RawResult)) print("Sucess, check log");
         
         else print("empty"); 
         
     }
 
 
     private void OnHideUnity(bool isGameShown) {
 
         print("FB: Hide Unity : " + !isGameShown);
        /* if (!isGameShown) Time.timeScale = 0;
         else Time.timeScale = 1;*/
     }
Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zzzzzz789 · Nov 12, 2015 at 06:10 PM 0
Share

What version of the Facebook SD$$anonymous$$ are you using? The latest is v7.2.2 available here. On the latest SD$$anonymous$$ you will replace the ShareCallback parameter with a IShareResult. Check the upgrade guide for details. Also be sure to walkthrough the Getting Started with Android.

avatar image georgios avate zzzzzz789 · Nov 12, 2015 at 07:04 PM 0
Share

I'm using v7.2.2, and I did follow the getting started with android walkthrough thoroughly.

The parameter thing I something I didn't know though, I'll try it as soon as I get home (about half an hour), I really hope that solves this.

avatar image georgios avate zzzzzz789 · Nov 12, 2015 at 09:20 PM 0
Share

I tried that, but nothing really changed :(

avatar image zzzzzz789 georgios avate · Nov 13, 2015 at 10:20 PM 0
Share

Can you reproduce your problem with the sample app included with the Facebook SD$$anonymous$$ for Unity? If so please immediately file a bug on https://developers.facebook.com/bugs

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by VarelaByakko · Apr 19, 2016 at 02:48 AM

Your code work in your Editor but no in android phone.

You need to change this:

 public void FBLogin() {
  
          FB.LogInWithPublishPermissions(new List<string>() { "email", "publish_actions" }, AuthCallback);
  
 }

To this:

 public void FBLogin() {
  
          FB.LogInWithReadPermissions(new List<string>() { "email" }, AuthCallback);
          FB.LogInWithPublishPermissions(new List<string>() { "publish_actions" }, AuthCallback);
          
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image subkiro · Dec 03, 2016 at 02:59 PM 0
Share

Thank you! this works perfect!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get a public profile permission facebook sdk 0 Answers

Facebook Login to create User account in my App 0 Answers

Broadcast Facebook Post To All App Users 0 Answers

Facebook login crash on Android. FB.Login 2 Answers

when i built apk for android in unity .I don't kn ow why its happening . is there anybody who can help me to fix this problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges