• 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 ShabihDesperado · May 08, 2015 at 12:26 PM · jarjni

Running/Debuging a jar

Hi,

I'm working with a plugin developed by another enterprise. They've released a native plugin for android and I have to port it to my Unity game so I took the jar and I did everything you should do to work with it. But the app send a single error line like this when I run it:

 E/MySDK(31849): Error using startMySDK:Unhandled error using MySDK

I don't have the source code so ... is there a way to debug a jar to locate the error?

Edit: I'm using adb logcat to get this error

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 Bunny83 · May 11, 2015 at 11:07 AM 0
Share

Well, how do you startup this SD$$anonymous$$? It looks like you're calling "start$$anonymous$$ySD$$anonymous$$" somewhere, is that correct? If so have you tried catching exceptions? If you don't have the source for the plugin, do you have a documentation? $$anonymous$$aybe you forget to initialize something / initialize it in the wrong order or your hardware might not be compatible with it.

There isn't much you can do to debug such a problem besides checking everything you're in charge of. Since you just provided the short description above we can do even less for you.

edit
I just saw you have "jni" as tag. Are you sure you use it "correct"? ^^ It's very easy to mess something up. Is the SD$$anonymous$$ a public one? Has it an online documentation? Can you share your code which initializes the SD$$anonymous$$? Also what's the SD$$anonymous$$ good for?

avatar image ShabihDesperado · May 11, 2015 at 11:25 AM 0
Share

Unfortunately the documentation doesn't help. I think I'm not missing anything (I've checked again). This function is all I have to do to initialize the plugin. This is what you can find in the documentation.

 $$anonymous$$ySD$$anonymous$$.start$$anonymous$$ySD$$anonymous$$(getApplicationContext(), 123456);

So this is what I've done.

 AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
 AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
 AndroidJavaObject app = activity.Call<AndroidJavaObject>("getApplicationContext");
 AndroidJavaClass $$anonymous$$ySD$$anonymous$$Class = new AndroidJavaClass("com.company.sdkname.$$anonymous$$ySD$$anonymous$$");
 $$anonymous$$ySD$$anonymous$$Class.CallStatic("startSD$$anonymous$$",new object[]{app,123456});

I'm doing something wrong? I don't catch any unity exception or JNI.

Edit: I don't know if it's good for nothing but someone want that I use it for Tracking.

Edit 2: I didn't know if it was public but I've found this GitHub so it must be: https://github.com/adform/adform-tracking-android-sdk The Documentation that I have is similar what is written there.

avatar image Bunny83 · May 11, 2015 at 12:59 PM 1
Share

Well, if that's the SD$$anonymous$$ the error is caused by an exception the SD$$anonymous$$ hasn't "expected". It catches the exception and returns this meaningless message:

   public static void startTracking(Context context, int trackPointId)
   {
     try
     {
       AppActivator.activateApp(context);
       if (handler == null) {
         handler = new $$anonymous$$ainHandler();
       }
       handler.setAppName(fakeTrackPoint.getAppName());
       handler.setParameters(fakeTrackPoint.getParameters());
       handler.setEnabled(enabled);
       handler.startTracking(context, trackPointId);
     }
     catch (IllegalArgumentException e)
     {
       logger.e(e.get$$anonymous$$essage());
     }
     catch (NullPointerException e)
     {
       logger.e("Service not started. To start, use startTracking(Context, int)");
     }
     catch (Exception e)
     {
       logger.e("Unhandled error using AdformTrackingSD$$anonymous$$");
     }
   }

This is a classical case of bad program$$anonymous$$g ^^. Catching all exceptions at the end and throwing them away is the best way to make a product impossible to debug...

Your options are:

  • try further debugging maybe by decompile the package and do those steps "manually" and see if you get an error that actualls makes sense.

  • try contact the author of this package.

  • use a different SD$$anonymous$$.

edit
ps: the decompiler i used is this one. Seems to work pretty well since the SD$$anonymous$$ isn't ofuscated ^^.

avatar image ShabihDesperado · May 12, 2015 at 07:31 AM 0
Share

I like your answer. Thank you. But I don't know yet how to re-compile the package. Probably the problem is that this package have some missing dependencies., like com.google.android.gms:play-services. I was trying to build a Google Android Project and insert there the plugin, but it's gonna be a mess if I have to do it every time I build it.

Edit ps: Do you know where I can get the JAR? In my android sdk I'm just finding the aar and it's not supported in unity 4.6.4 ps2: I've tried adding to the project the classes.jar of the aar and still not working.

1 Reply

· Add your reply
  • Sort: 
avatar image
-3

Answer by TheCreeperMiner · May 08, 2015 at 06:25 PM

I don't understand you much, but I think you wan't java file inport to unity.

If you want to do that, then use Javascript, not java, "Javascript".

And then write your code aka

 If.Input(GetKeyDown) "g"
 
 Do ToggleLightOff
 
  { else
  
  do ToggleLightOn
Comment
Add comment · Show 2 · 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 ShabihDesperado · May 11, 2015 at 09:00 AM 1
Share

Are you a troll?

avatar image ForeignGod · May 11, 2015 at 10:27 AM 0
Share

How does this help him?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 People are following this question.

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

Related Questions

[Android] Call .jar function on render thread using JNI 0 Answers

JNI problems in unity 1 Answer

Using JNI without Android? 1 Answer

How to package resources which are in a Jar file 1 Answer

How to read assetbunde from Application.datapath on android 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