• 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 ArinCherryBlossom · Aug 31, 2016 at 11:29 AM · unity 5java

Smack (XMPP) version check problem only occurs on Unity

Hello,

I know that this may not be unity question, but I have no answer from smack community. So let me ask my question... there will be some users who used smack with unity.

I'm developing an Unity application (5.4.0f3) with Java/Andoid libraries as plugin. As server uses XMPP, I use smack to communicate with server. (Server is coded with prosody.im)

When I test codes without Unity, there is no problem. I can run application with smack via PC(win/java) or native Android app. But problem occurs when I run it with Unity.

I attached logcat below. Do you have any idea? I googled this error but there were not many questions and no answers...

Thanks in advance

p.s. Error occurs at this line (Class#2.java:49)

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder();

especially in this method, code below occurs problem.

SmackConfiguration.getVersion();

  • Error Log --

Could not determine Smack version java.lang.NullPointerException: lock == null at java.io.Reader.(Reader.java:64) at java.io.InputStreamReader.(InputStreamReader.java:122) at java.io.InputStreamReader.(InputStreamReader.java:57) at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:61 ) at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 ) at org.jivesoftware.smack.ConnectionConfiguration.(ConnectionConfiguration .java:38) at [remove package name for security issues].(Class#2.java:49) at [remove package name for security issues](Class#1.java:120) at [remove package name for security issues](Class#0.java:193) at [remove package name for security issues].MainActivity$3.run(MainActivity.java:70) at java.lang.Thread.run(Thread.java:818) FATAL EXCEPTION: Thread-22292 Process: com.aibrain.giar.lite, PID: 23634 java.lang.Error: FATAL EXCEPTION [Thread-22292] Unity version : 5.4.0f3 Device model : samsung SM-N920K Device fingerprint: [remove for security] Caused by: java.lang.ExceptionInInitializerError at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 ) at org.jivesoftware.smack.ConnectionConfiguration.(ConnectionConfiguration .java:38) at [remove package name for security issues].(Class#2.java:49) at [remove package name for security issues](Class#1.java:120) at [remove package name for security issues](Class#0.java:193) at [remove package name for security issues].MainActivity$3.run(MainActivity.java:70) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:11 9) ... 7 more Caused by: java.lang.IllegalArgumentException: is == null at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1634) at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:155) at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:148) at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:11 6) ... 7 more Force finishing activity com.aibrain.giar.lite/.MainActivity

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 connatty · Oct 04, 2016 at 10:02 PM 0
Share

I'm having the exact same problem, did you end up finding a solution? Cheers

avatar image naXa · Oct 07, 2016 at 11:02 PM 0
Share

$$anonymous$$e too. I'll try to fix this.

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bilelmnasser · Apr 24, 2019 at 01:10 PM

Hi, there is in my github Working Library of XMPP implementation.

Comment
Add comment · 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
0

Answer by ArinCherryBlossom · Oct 21, 2016 at 07:28 AM

After all, I made intermediate server for XMPP connection...

Actually I don't like this way, because I run two servers.

@naXa did you succeed to fix?

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 naXa · Nov 18, 2016 at 01:38 PM 0
Share

Yes, I did. I'll post a solution in my free time.

avatar image solinv naXa · Dec 01, 2016 at 04:00 PM 0
Share

I'd be curious as well, care to explain in rough words?

avatar image
0

Answer by naXa · Dec 02, 2016 at 09:14 AM

The problem is that all plain text resources from jar file are not included in dex file during conversion. And Smack (former ASmack) library crashes because it can't access version file. I am not going to argue with Smack developers whether it's a good idea to halt if you can't read some resources file...
In rough words my solution is to repack APK file and include this missing version file and other potentially useful resources from jar. After repacking you need to sign APK file again.

List of resources:

  • org.jivesoftware.smack library:
    • jul.properties

    • smack-config.xml

    • version

  • org.jivesoftware.smack.im
    • smackim.xml

    • smackim.providers

  • org.jivesoftware.smack.tcp
    • smacktcp.providers

  • XPP3_1.1.4c_VERSION

Also I would like to share my shell script (Linux) for repacking APK file.

Script source code

 #!/bin/sh

 echo "[INFO] Removing signature"
 zip -d "$1" "META-INF/*"
 echo "[INFO] Adding resources"
 aapt add -v "$1" META-INF/services/* org.jivesoftware.smack/* org.jivesoftware.smack.im/* org.jivesoftware.smack.tcp/* XPP3_1.1.4c_VERSION
 echo "[INFO] Psst! Want to know a secret password? Try 'android' ;)"
 jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore "$1" androiddebugkey
 echo "[INFO] Repacking is done!"

Usage

 sh ./repack.sh ./project.apk

Requirements:

  1. zip, aapt, jarsigner tools should be available from terminal.

  2. ~/.android/debug.keystore file should be present. It's a default debug keystore that is generated when you perform the first build in Eclipse / Android Studio. (more details)

By default this script uses debug key for signing your application. You can use your own key, just modify jarsigner line.

@ArinCherryBlossom, @solinv, @connatty, you may be interested in this answer.

Comment
Add comment · Show 3 · 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 solinv · Dec 02, 2016 at 10:22 AM 0
Share

Great write-up, thanks for sharing!

avatar image ArinCherryBlossom · Dec 08, 2016 at 04:49 AM 0
Share

Great answer! Thanks. I'll try it

avatar image sagar_arvaan · Jan 28, 2017 at 11:34 AM 0
Share

hello I am getting same error, any solution ?

avatar image
0

Answer by sagar_arvaan · Jan 31, 2017 at 08:46 AM

I got solution please check this my answer in Stack Overflow: Check here

Comment
Add comment · 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

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

8 People are following this question.

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

Related Questions

Touch JoyStick problem - JavaScript!! 0 Answers

How to use Unity3D physics to make a robot hand move and grab an object? 1 Answer

yield WaitForSeconds(1) ends with this error:ArgumentException: method return type is incompatible 2 Answers

AndroidJava and Implementing java.util.List 0 Answers

Opening another Unity app with java intent, sending a parameter and reading it in the second Unity app 3 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