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 silentassassin47 · Jun 23, 2015 at 12:54 PM · androiddllxmlserializer

Using a predefined dll in an android build

I have been creating a game which can run on both Windows and Android. I already have a working android build but decided to add save and load feature to both the Android and Windows builds. For this I used XML serialization as described here.

My job is to read from an XML file like a database and for this purpose I also use a XML editor. The editor shows that encoding is done as Windows-1252

 <?xml version="1.0" encoding="Windows-1252"?>

So, while building my Windows build I had to include 2 dll files into Assets/Plugins folder as mentioned here. This made the Windows build run as I wanted. The problem starts when I try to run the Android build. It shows the same problem which occurred to me in the Windows build when I didn't include the dll's.

So, my question is if there is a quick way to use the 2 dll's mentioned in the link in the android build, if possible, without recompiling the dll's. Is there any other workaround(Will changing encoding format do?)

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by silentassassin47 · Jun 30, 2015 at 05:48 PM

So, I will be answering my own question here. After a lot of research I found that the problem was neither with the dll's or with the encoding. The required file was just not found by Android. Since Android uses an archive to ship builds, all the files are zipped up in the archive. To make sure that your predefined file is shipped with the build, make a folder called StreamingAssets inside the Assets folder as mentioned here. This will make your file present in the apk archive.

Now after you install the apk file in your android system, your required file does not get automatically installed. You have to do explicitly. You have to use the WWW class inside your project to transfer the required file to the required directory like below.

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class Copyxml : MonoBehaviour
 {
     WWW www;
     
 #if UNITY_ANDROID && !UNITY_EDITOR
     void Start ()
     {
         StartCoroutine("Downloader");
     }
 
     IEnumerator Downloader ()
     {
 
         www = new WWW ("jar:file://" + Application.dataPath + "!/assets/XMLFILE.xml");
         yield return www;
         if (www.isDone == true)
         {
             File.WriteAllBytes (Application.persistentDataPath + "/XMLFILE.xml", www.bytes);
         }
     }
 #endif
 }

And you are done!!

Answered for the convenience of others.

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 Thadeous · Aug 31, 2016 at 07:04 PM 0
Share

Hey, does this method also work on dll-s? I am having trouble moving a specific dll into a directory afther the project is build. Can you help me?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Referencing a DLL in C# 0 Answers

Loading Xml file issues 0 Answers

DLLs work on Windows but not on Android 1 Answer

I have a quiz game that loads questions using an xml file. The game works well on editor,but not on android.Help Pls 0 Answers

How do I include added dll's to a android apk build? 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