Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by stan4unity · Feb 04, 2012 at 11:20 PM · androidcrashplugin

android plugin app crashing

Hi,

I did follow official unity documentation to do eclipse based unity project. Then I read official docs how to call native java code using plugins. I created test project and was able to call from c# java method I created on my activity of android project which extends UnityPlayerActivity.

what I did was putting method on main activity and in c# called it this way

 AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
 AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); 
 Debug.Log("what am I?:"+jo.Call<string>("toString")); 
 jo.Call("myMethod");

 

This resulted to printing activity name and calling my method on the main activity object as expected.

Now with my real porject I'm using Qcar qualcomm library and this changes a situation a little bit because my activity which extends UnityPlayerActivity is not the main one now. Qcar activity is and it must be main one for some reason otherwise it does not initialize itself properly. My app is working fine this way.

Problem is that now when I call

 AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); 
 Debug.Log("what am I?:"+jo.Call<string>("toString")); 

It does not give me my activity object but instead qcar one which I have no control over.

I still can access my activity class by

 AndroidJavaClass jc = new AndroidJavaClass("com.mypack.myapp.myactivity"); 

but this is in static way, its not constructed activity object. I did create static method on it which constructs new plain object and returns it. This was working ok as well but calling any method on this new constructed plain object crashes application completely. With nothing meaningful in logs. just signal 11 (SIGSEGV), fault addr 00000000.

also tried to construct my own plain java object using this

 AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("com.mypack.myapp.myplainobject"); 
 Debug.Log("what am I?:"+jo.Call<string>("toString")); 

results in nothing being logged.

what is a proper way to create or call own object on native code and not getting segfault? Or is there a way how to get reference to my app activity other than currentActivity?

Thanks a lot. S.

Comment
Add comment · Show 2
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 aphexyuri · Feb 20, 2012 at 01:38 AM 0
Share

Hi, I'm having a similar issue and I was wondering you found an anser for this yet?

avatar image stan4unity · Feb 20, 2012 at 08:12 AM 0
Share

Hi, yes I did but can;t remember exactly how cos I found more things which were wrong at the same time. actually I was creating class that was implmenting activity but was not registred as activity in manifet file. Then when it was in manifest It was created actueally on run time itself so creating it again was not good as well. Than I removed activity implementation fron the class and in methods I called I was tryint to run some stuff which required to be run on UI thread not on backround this was creating problems as well. I can't remember now at what stage I had this issue. Basically it was my lack of conceptual understanding of things. It was not easy to understand and put things right but that was my problem and now I have it working as needed.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Ad plugins on Android leads to extra crashes 0 Answers

Unity3D Android plugins and SIGSEGV 0 Answers

Game Thrive (One Signal) causes game to crash when calling init method. 1 Answer

App crash after LoadLevel from a specific scene 1 Answer

Android lag on Nexus 7 (2012) 0 Answers


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