Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How did Shadowgun reduced APK to 6 MB?

Discussion in 'Android' started by zalogic, Nov 9, 2011.

  1. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    I don't think it would be a problem if you zip up the eclipse project, and include it in the unity package to be given to the asset store. Just make it clear that that zip needs to be extracted and so on in some readme file.
     
  2. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Sounds great! How would this handle app updates? Would you simply reupload the apk with a different version number which could trigger the data archive to redownload? Would the data need to be tagged with a version number?
     
  3. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Currently the implementation of handling updates is left to the user. But that is in the works too. ;)

    Basically the Installer will have an internal version counter that must be incremented before uploading to the market. When it first starts after the user updates his app, it will check for the existance of a previous version tag of the Installer. If it's not present, it will re-download the game data again. (this means you already changed the game data on your server)
    This way there is no extra complication with more confirmation messages to the user and other stuff and it will just let the Android Market handle update notifications and stuff like that.

    But this is pending along with some weird bug issues that we're found and crushed. ;) For now, anyone can extend the functionality of the Installer to do whatever they want.

    Stay tuned.
     
    Last edited: Jan 14, 2012
  4. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Great

    I think an option to postpone an update would be nice, since they might 'update all' in the normal market, then run the app out of wifi range and be forced to update to play.
    Maybe it could detect that there's no wifi and simply play the old version without any notification. If you are on wifi you could still show a button to postpone. eg 'Update game data over wifi' and 'Postpone update'
     
  5. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Or that. :) But this is a bit off the scope of the build tool right now. The Installer for now does what is suppose to: download the separated game data from a server and the tool does the build magic. But I will take this feedback into account and I will first concentrate on automatic the setup process of the tool because it seems it's a bit problematic for some users.

    Also, thanks to a good friend Taj (aka Syllus) I've found an issue with the tool that can cause a DEX file generate error. If anyone has this issue although the tool setup was done correctly, this is caused by the fact that the Unity project is in a path with spaces in the name and there's a bug related to this.
     
  6. stijnvdb

    stijnvdb

    Joined:
    Feb 9, 2010
    Posts:
    11
    floky...you're the man.

    It took me a while (mostly because I was completely unfamiliar with the Eclipse IDE) but finally managed to set it up. Just following the readme files and reading the comments here solved all the issues I encountered along the way. The game now runs better and loads faster than it ever has with AssetBundles!

    For all those still struggling, here's some things that you should double check at least 50 times whenever you get errors (all of it is mentioned in readme files and comments here though):

    - PostProcessBuildPlayer_Android, make sure that the paths specified in the ENV{'PATH'} variable are correct, and set the 2 variables below
    - Eclipse: start from an empty project, Import -> Existing Projects into Workspace and load up floky's UnityInstaller project
    - import the classes.java file as described in this thread
    - In InstallerActivity I changed the getGameDataUrl to return the complete link to my .apk file and changed InstallerBaseActivity to return just getGameDataUrl
    - Make sure the AndroidManifest.xml in the Eclipse project has the same bundle name as your Unity project
    - In your Unity project, don't forget to edit your AndroidManifest.xml according to floky's example manifest file
    - Make sure your Unity project does NOT have spaces int it (as floky says in the above post - you'll get a DEX generate error)

    Thanks again for this amazing tool floky! I had been struggling with the apk file size issue for months, even converted the whole project to work with AssetBundles (which was slow as hell + unstable) and back...

    I will sleep like a goddamn baby tonight.
     
  7. stijnvdb

    stijnvdb

    Joined:
    Feb 9, 2010
    Posts:
    11
    just one question: how do you handle the security issue of someone finding out the remote gameData.apk location and installing it directly? I tried that just now to see what would happen - adb reports INSTALL_FAILED_DEXOPT. Do you think it's possible for a potential hacker to get around it at all though?
     
  8. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    First of all thanks! ;) I'm glad it helped. A new improved version of the tool with a minimalistic and automated setup is comming soon so all the above issues will be solved and the difficulty of setup will dramatically decrease. ;)

    Second, about the modification you said you did setting the direct link to your apk file... I don't know if it's what you really want for your final release. The base installer detects at run-time what type of GPU the device has and it will try to download the corresponding game data apk file from the URL you specify. For the final release you will have to build your unity project 4 times(for now:D) to generate 4 types of game data files for each time changing the Texture cimpression type in the Build Settings: Generic, Snapdragon, Tegra and PowerVR. This way the installer will download the APK with the assets best optimized for that device and it will run even faster tham using a game data apk generated with Generic texture compression.
    But I will better explain this in the next version together with a sample unity project.

    In terms of security...like I said somewhere in this thread: the game data apk can't be installed. The security is the same as the one offered by the Android Market...poor. :) Also all games having their resources downloaded on the external storage suffer from the same security issue. The game data apk is not an application even if it's packaged like one. It doesn't contain any android code inside to run it.
    But the good thing is that security can be further improved manually, knowing in advance the exact game data apk sizes and what they contain. Using Asset Bundles has the same security flaws.
    All can I say at the moment is obfuscate obfuscate obfuscate...:)
     
  9. stijnvdb

    stijnvdb

    Joined:
    Feb 9, 2010
    Posts:
    11
    Yeah I know, I just took it out for now because I just needed it to work for testing :) Once we're out of the debugging phase and start prepping for release I'll definitely change it back and make the 4 game data files, as this is indeed a very nice optimization feature!

    Thanks for your answer on the security part, it makes sense now :)
     
  10. Default117

    Default117

    Joined:
    Mar 13, 2011
    Posts:
    134
    This is fantastic floky! Loving the progress you have made so far, i can't wait to dig into this and implement it into our project which we'll really need!
    Roughly how long does it take to implement this process into an existing project? Just so that i have some idea of a scope and when i should get my project done by in time for upload. Also i'm assuming at this stage it is functional enough to be used in a project?

    Another question i still have that i still haven't been able to get an answer for from anyone the last few months is that - are we able to find out a link to the marketplace where we can upload our data files too? I'd like to use this installer to grab the extra data files straight from the marketplace instead of my own server to save costs. And seeing as though Google already allows us to upload 2x 2gb extra apk's, i'm sure this is a good option for everyone!


    //Edit//
    So i asked a question on Overstack and it seems that my assumption is correct. You should be able to just access the data files by doing something like this:
    Code (csharp):
    1. market://details?id=com.example.your.datafile1
    2. market://details?id=com.example.your.datafile2
     
    Last edited: Jan 20, 2012
  11. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    With the current tool version the setup process for someone new with Eclipse and Android dev the process could take 1 - 2 hours if everything works smoothly. With the new version I'm working on, the setup process of the tool in a new project should take up a few mins because I've managed to automate most of the setup and minimize the required user settings. It's not completely finished cause I have some problems right now but if you stay tuned on this thread the new version should pop-up soon. :)

    The tool is functional and can be used in a project because we're using it and it worked so far. :)
    Don't know too much about too many other users that have tried it yet. Some have some issues setting it up, others don't. But most of the common problems have been discussed and solved in this thread. For example the user "stijnvdb" managed to use it and confirmed that it worked for him.

    Regarding the Market data files...I never did find official news about that. This was pending a few months ago. I don't know if it really works yet to access the files from the market. Where can you upload them?
    If you check out their official APK uploading documentation you will see nothing mentioned about the 2GB data files:
    https://support.google.com/androidmarket/developer/bin/answer.py?hl=en&answer=113469

    Cheers!
     
    Last edited: Jan 20, 2012
  12. Default117

    Default117

    Joined:
    Mar 13, 2011
    Posts:
    134
    Sounds great!
    I'll give this a go today as i finished up the project friday. Looking really forward to your new installer, it sounds amazing!

    As for the data files, i uploaded 2 16mb apk's and there were no issues with it. I'm about to upload 2 50mb apk's and see what happens.
    When you upload your project to the marketplace there is no specific place to upload "extra data files", only a single area you can upload files. But it allows you to have multiple files, so i'm going to assume that this is the area you can upload your data files to. I might email support to clarify this.


    //edit// Pretty simple process! Downloaded, installed Eclipse and ran through the process to get the installer implemented. Everything so far seems to work fine. I'm up to the part where i want to build the unity app, but i keep on getting the following error when i build:

    Code (csharp):
    1.  
    2. Resource re-package Failed!
    3. package -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "/Users/dewald/AndroidDev/android-sdk-macosx/platforms/android-10/android.jar" -F bin/resources.ap_
    4. Configurations:
    5.  (default)
    6.  hdpi
    7.  
    8. Files:
    9.   drawable/app_icon.png
    10.     Src: () res/drawable/app_icon.png
    11.     Src: (hdpi) res/drawable-hdpi/app_icon.png
    12.   values/strings.xml
    13.     Src: () res/values/strings.xml
    14.   AndroidManifest.xml
    15.     Src: () AndroidManifest.xml
    16.  
    17. Resource Dirs:
    18.   Type drawable
    19.     drawable/app_icon.png
    20.       Src: () res/drawable/app_icon.png
    21.       Src: (hdpi) res/drawable-hdpi/app_icon.png
    22.   Type values
    23.     values/strings.xml
    24.       Src: () res/values/strings.xml
    25. Including resources from package: /Users/dewald/AndroidDev/android-sdk-macosx/platforms/android-10/android.jar
    26. applyFileOverlay for drawable
    27. applyFileOverlay for layout
    28. applyFileOverlay for anim
    29. applyFileOverlay for animator
    30. applyFileOverlay for interpolator
    31. applyFileOverlay for xml
    32. applyFileOverlay for raw
    33. applyFileOverlay for color
    34. applyFileOverlay for menu
    35. applyFileOverlay for mipmap
    36. Processing image: res/drawable/app_icon.png
    37.     (processed image res/drawable/app_icon.png: 99% size of source)
    38. Processing image: res/drawable-hdpi/app_icon.png
    39.     (processed image res/drawable-hdpi/app_icon.png: 99% size of source)
    40.     (new resource id app_icon from drawable/app_icon.png #generated)
    41.     (new resource id app_icon from hdpi/drawable/app_icon.png #generated)
    42. AndroidManifest.xml:5: error: No resource identifier found for attribute 'hardwareAccelerated' in package 'android'
    43.  
    44. UnityEngine.Debug:LogError(Object)
    45. PostProcessAndroidPlayer:PostProcess(BuildTarget, String, String, String, String, String, String, BuildOptions)
    46. UnityEditor.HostView:OnGUI()
    47.  
    I'm guessing it has something to do with the android manifest or the post process.

    //edit 2//
    I went into the manifest file and deleted the line that read hardwareAccelerated. I tried just changing it to false to see what happens, but i get the same error. It builds now, but it builds the complete apk and then just shows me the final folder for it and that's it. The installer builder does not pop up at all.

    //edit 3//
    Alright! The builder now launches, there was just a problem with the folder structure and not being able to locate the finder.
    Still worried about the manifest issue with hardware accelerated though...


    //edit 4//
    Alright, i've had a play with the multiple APK uploading to the marketplace, and i'm almost convinced now that it is not possible with the current method. You can upload multiple APK's for filtering purposes, but there is no way it seems to get a link to these files perhaps for security reasons. I cannot find any dedicated areas to upload data files specifically.
    Private servers seem to be the way to go until Google decides to stick to their work from May 2011 and actually introduce storage space for additional data files. Which is exceptionally frustrating.

    Back to the actual topic at hand. The Installer. When i upload the installer to the marketplace, i keep on getting an error stating that i cannot upload an APK which has been signed with the debug keystore. Even though i did sign it with a custom keystore. When the APK's get split, does this revert back to the debug keystore or what? I think something has been mentioned about this before, i'll look through the responses again.
     
    Last edited: Jan 23, 2012
  13. srrngames

    srrngames

    Joined:
    Jul 17, 2011
    Posts:
    11
    Hey, me too! This is happening on our Asus Transformer...

    What was the fix here? Any idea if this is device-specific, or related to this thread?

    My fun, fun log:

    Code (csharp):
    1.  
    2. I/ActivityManager(  136): Starting: Intent { flg=0x10000 cmp=com.srrngames.gamename/com.unity3d.player.UnityPlayerNativeActivity } from pid 5246
    3. D/dalvikvm( 5246): Trying to load lib /data/data/com.srrngames.gamename/lib/libmono.so 0x407dc7d8
    4. D/dalvikvm( 5246): Added shared lib /data/data/com.srrngames.gamename/lib/libmono.so 0x407dc7d8
    5. E/linker  ( 5246): ERROR: Library '/assets/libs/armeabi-v7a/libmono.so' not found
    6. W/dalvikvm( 5246): JNI_OnLoad returned bad version (0) in /data/data/com.srrngames.gamename/lib/libmono.so 0x407dc7d8
    7. D/AndroidRuntime( 5246): Shutting down VM
    8.  
    Anybody have any ideas? I'm sure it's something small (it always is) :/

    Thanks for all your hard work, floky, and to those who have helped you get this far! :D

    Solved: the AndroidManifest.xml in Plugins/Android/ was getting overwritten by one of our Editor scripts, so it wasn't properly being set to the one found in Unity Android Build Tools/InstallerAndroidBuilder/Builds/SampleAndroidManifest/
     
    Last edited: Jan 29, 2012
  14. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    When publishing an update to the next Android app, I think I'm going to try this method and see how it works. If it works faster than Asset bundles it will be a huge win. I look forward to the "easy-to-use" release. I also hope that the Unity folks read this and try to implement something similar in the next Unity version for Android as this is a serious problem that Asset bundles aren't a 100% solution for.
     
  15. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hi Default117, regarding your signing problem it's a minor issue that's already solved in the next version of the Android Builder Tool.
    You must NOT sign your APK with a custom keystore using Unity if you intend to generate the APK using the Android Builder Tool. That's because the current version of the tool re-signs the APK's with the android debug keystore after Unity. After the APK's are generated you must only sign the Installer APK and you must do that using the command line like this:
    The next version of the tool has a built-in easy to use GUI that allows you to sign the generated APK files using a custom keystore. Meanwhile you can learn more about signing from the command line here:
    http://developer.android.com/guide/publishing/app-signing.html
    Hope this helps.



    Hi srrngames! This issue I had was fixed and the solution was detailed here:
    http://forum.unity3d.com/threads/112703-Override-Unity-Data-folder-path
    It was actually a very stupid mistake I was doing.



    Hi Ferazel, I will try to release the new version as soon as possible. I have no intention of keeping it only to myself. :D But right now I'm being delayed a bit because of some personal problems, but I will get back on track very soon.


    Thank you for all your support and patience guys! Keep in touch.
     
    Last edited: Jan 24, 2012
  16. Default117

    Default117

    Joined:
    Mar 13, 2011
    Posts:
    134
    Ah thats what i thought!
    Other than that hiccup everything works fine! Really didn't take too long to get this all set up, very quick in fact, so i can imagine that your new automation tool will be extremely fast!

    Thanks again for the fantastic work your doing, i've certainly learnt a lot from it.
     
  17. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I'm glad it helped you!

    Cheers! ;)
     
  18. colargol

    colargol

    Joined:
    Mar 31, 2010
    Posts:
    65
    1. Which CDN will you recommend for data?
    On Amazon CloudFront, with small piracy (like 0.5 mil downloads), we will have to pay around 4000 $ for one update of our game.

    2. Anybody have some numbers, how big the piracy actually is?
     
  19. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    I think that if you wanted affordable solution would be build it yourself as for example on linode.com, the cheapest package which would be more than sufficient, starting from 19.95$ / month with 200 GB data transfer, multiply that if for example you wanted to build 4 node for each region (US,EUROPE,ASIA, North America), so you would only need 4 node in which you pick where would be the location nearest in each region.
     
  20. spartan

    spartan

    Joined:
    Mar 10, 2010
    Posts:
    174
    Hi Floky,I don't want to bother you, but I would like to know when do you expect to release the new version of your tool, I'm watching this thread every day :)
     
  21. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hi there! You're not bothering at all. :) I''ve been through a few busy weeks and I didn't have too much free time to spend on the tool. But as an estimate I expect to release the new version sometime during this week. I'm sorry I can't be more precise because of my free time fluctuation lately. :D
    The new version won't require any more setup done in any file or any system path variable setting. It will just require the usual Installer eclipse project importing setup which should be known by anyone with basic knowledge of working in Eclipse.
    Also the rules of package naming in the android manifest will be a little more simpler and less confusing.

    Stay tuned. ;)
     
    Last edited: Jan 30, 2012
  22. srrngames

    srrngames

    Joined:
    Jul 17, 2011
    Posts:
    11
    Previous bug? Squashed.

    Disclaimer: this bug seems to have something to do with our current project setup, as a new Unity project seems to work just fine.

    New issue on installer launch:

    Code (csharp):
    1.  
    2. D/Installer(26418): onInstallerInit( ) called!
    3. D/AndroidRuntime(26418): Shutting down VM
    4. W/dalvikvm(26418): threadid=1: thread exiting with uncaught exception (group=0x40243760)
    5. E/AndroidRuntime(26418): FATAL EXCEPTION: main
    6. E/AndroidRuntime(26418): java.lang.NullPointerException
    7. E/AndroidRuntime(26418):    at com.userCustom.installer.InstallerActivity.onInstallerInit(InstallerActivity.java:75)
    8. E/AndroidRuntime(26418):    at com.mobilitygames.installer.InstallerBaseActivity.installerInit(InstallerBaseActivity.java:160)
    9. E/AndroidRuntime(26418):    at com.mobilitygames.installer.InstallerBaseActivity.handleMessage(InstallerBaseActivity.java:193)
    10. E/AndroidRuntime(26418):    at android.os.Handler.dispatchMessage(Handler.java:95)
    11. E/AndroidRuntime(26418):    at android.os.Looper.loop(Looper.java:132)
    12. E/AndroidRuntime(26418):    at android.app.ActivityThread.main(ActivityThread.java:4123)
    13. E/AndroidRuntime(26418):    at java.lang.reflect.Method.invokeNative(Native Method)
    14. E/AndroidRuntime(26418):    at java.lang.reflect.Method.invoke(Method.java:491)
    15. E/AndroidRuntime(26418):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
    16. E/AndroidRuntime(26418):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
    17. E/AndroidRuntime(26418):    at dalvik.system.NativeStart.main(Native Method)
    18. W/ActivityManager(  142):   Force finishing activity com.srrngames.gamename/com.userCustom.installer.InstallerActivity
    19.  
    Edit:
    Line 75:
    Code (csharp):
    1.  
    2. btnOk.setOnClickListener(this);
    3.  
    The issue is clearly btnOk being null, which is set just above in line 70:

    Code (csharp):
    1.  
    2. btnOk = (Button)findViewById(R.id.btnOk);
    3.  
    Solution: Remove OpenFeint PostProcess script and all files in Plugins/Android/ ;)

    Finally, everything seems to be working. +1, floky. +1.
     
    Last edited: Feb 1, 2012
  23. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Really? Does OpenFeint postprocess script do something that crashes the installer? :) Can you upload it here please so I can check it out and maybe integrate something in my tool that will avoid such cases in the future?

    Also, I don't understand why you had to remove all other plugins in Plugins/Android/. That is where the installer jar file must be placed. What other plugins did you use in the Plugins/Android folder? :)

    Thank you for your feedback srrngames. This will be very helpful for other users.

    Cheers! ;)
     
  24. lebasp

    lebasp

    Joined:
    Aug 30, 2011
    Posts:
    11
    Hi floky, i sent you a private message, but i`ll paste here


    Once I run the installer I got an exception (log below), i guess i did something wrong during the config
    thank you in advance

    Code (csharp):
    1. 02-02 13:25:26.225  5281  5281 E AndroidRuntime: Uncaught handler: thread main exiting due to uncaught exception
    2. 02-02 13:25:26.225  5281  5281 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{im.maya.legendaryheroes/com.unity3d.player.UnityPlayerActivity}: java.lang.RuntimeException: unable to link library
    3. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2558)
    4. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2574)
    5. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread.access$2400(ActivityThread.java:121)
    6. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)
    7. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
    8. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:136)
    9. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:4425)
    10. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at java.lang.reflect.Method.invokeNative(Native Method)
    11. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Method.java:521)
    12. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
    13. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
    14. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at dalvik.system.NativeStart.main(Native Method)
    15. 02-02 13:25:26.225  5281  5281 E AndroidRuntime: Caused by: java.lang.RuntimeException: unable to link library
    16. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at java.lang.Runtime.nativeLoad(Native Method)
    17. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at java.lang.Runtime.loadLibrary(Runtime.java:476)
    18. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:557)
    19. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at com.unity3d.player.UnityPlayer.<init>(Unknown Source)
    20. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
    21. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    22. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
    23. 02-02 13:25:26.225  5281  5281 E AndroidRuntime:    ... 11 more
    24. 02-02 13:25:26.233  1257  1260 I Process : Sending signal. PID: 5281 SIG: 3
    25. 02-02 13:25:26.241  5281  5283 I dalvikvm: threadid=7: reacting to signal 3
    26. 02-02 13:25:26.241  5281  5283 I dalvikvm: Wrote stack trace to '/data/anr/traces.txt'
    27.  
     
  25. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    There are many things that could cause these errors lebasp. The most usual mistake is to not set the android package name from the Installer eclipse project to be the same name as the Unity project bundle name. But some users have experienced issues when trying to use Openfeint Android plugin together with the Android Build tool. I can't tell you for sure but if you send me an archive containing your "Assets/Plugins/Android/" folder and the Installer Eclipse project to see how you configured everything I might be able to help you

    Or if you are testing with a simple Unity Project I could better help you if you send me an archive of the entire Unity project together with the Installer Eclipse project.
     
  26. lebasp

    lebasp

    Joined:
    Aug 30, 2011
    Posts:
    11
    @floky

    i`ve pmed you the archive with the android folder and the eclipse project
     
  27. lebasp

    lebasp

    Joined:
    Aug 30, 2011
    Posts:
    11
    sorry to bother you again =P

    i forgot to ask

    ive looked briefly at some parts of your template code to check if it checks for updates of the game and couldn`t find it, so where can i check to start implement (if not) this feature?
    and by the way, does the next version will have this feature?
     
  28. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I've already said about updates checking here:
    http://forum.unity3d.com/threads/11...ed-APK-to-6-MB?p=800213&viewfull=1#post800213

    I will try to squeeze this in the next version. :) I'll see how much free time I can put aside. It shouldn't be something too difficult to implement. I think testing it is gonna be harder for me. :D

    I figured to avoid reinventing the wheel by making the installer check the server for updates and let the Android Market app handle update notifications cause it already has this system integrated in it. (like I mentioned in the above posted link)
     
  29. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Respect m8!
    Many thanks for your hard work!
     
  30. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I've looked in the android folder and in the Installer eclipse project you've sent me.

    So, the first thing is first: you messed up the Installer Eclipse project. You've created some empty packages, you've renamed a package from the sources that shouldn't have been renamed and more that doesn't matter now. :) I think you got confused when I said in the instructions file to rename the Installer Eclipse project android package name to be the same name as the one from your Unity project bundle name.
    To edit the android package name means to open the AndroidManifest,xml with Eclipse and it will show you a nice editor with a lot of fields to edit the manifest file. It's like a helping editor that hides all the raw xml info and displays it in a more user friendly way. At the top of that editor interface you will see an edit box called Package Name. That's what you have to change.
    When you change that, Eclipse will ask you if you want to automatically change all references to that package in the project. After you click Yes, you will notice a compile error. That's because Eclipse fails to change one reference to that package name in the file InstallerActivity.java. You will see it highlighted. You just have to manually change that your self and the project will be compile-able again.

    Another common mistake for users not familiar with Eclipse IDE is to compile and export to a JAR along with compile errors. Eclipse by default has an option that tells the compiler to ignore java compile errors when exporting the installer JAR that I mention in the setup instructions. You MUST disable that option to make sure you are not creating a JAR with errors because it will obviously crash when you will add it to your unity project. ;)

    So, like I said before, if you are new to Eclipse IDE, please try to setup the Android Builder Tool using a very simple Unity project that doesn't use any other android plugins like (TapJoy or Openfeint) so I can make sure you're not having any other extra issues because of them. After you try the setup again with a simple Unity project, PM me again if you have problems but this time send me the Unity project and the Installer Eclipse project in an archive so I can debug your problem easier. ;)

    Hope this brings a little help. :D
     
    Last edited: Feb 5, 2012
  31. spartan

    spartan

    Joined:
    Mar 10, 2010
    Posts:
    174
    @floky do you will publish your new installer in this thread?
    Thanks
     
  32. buffonomics

    buffonomics

    Joined:
    Jun 10, 2009
    Posts:
    59
    floky! You're the latest in my short list of heros :)
     
  33. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I think I will make a new thread for the new AndroidBuilder version with a better suited forum thread title.


    Thanks buffonomics! ;)

    For anyone else wondering about the new tool version progress: it's 75% complete! Still have some android platform specific build problems to solve but it's going well so far.
    And for the extra news: yes the new version will support auto-updates as it was described in a previous post ;)(http://forum.unity3d.com/threads/11...ed-APK-to-6-MB?p=800213&viewfull=1#post800213)
     
  34. Dreeka

    Dreeka

    Joined:
    Jul 15, 2010
    Posts:
    507
    Good to hear it is near to finish! :)
     
  35. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I've just hit a VERY annoying problem that made me delay the tool! Thanks to the feedback of some users i've managed to track down an issue that can most often happen when trying to build the project with the android tool while also including other android plugins that have their own android UI xml interfaces (for example TapJoy).
    And I call upon all the Java Android experts out there to help me find a solution to this issue because it will be a major benefit for all mankind using Unity to build for Android. :)

    What happens actually?
    ==========================
    To make a long story short, you all know that an Android application has the user interface stored in the "res" folder, in various xml files (be it a layout or a xml describing a drawable element). Cool! What's cooler is also that each of the UI and non-UI elements (like strings) described in these xml files have a unique id name that is also stored in the xml.
    But here comes the un-cool part. Each Android project has an automatically generated R.java class file that holds "public static final int" definitions for each of the id names in it's xml files. So actually this class stores a unique integer ID for each id name in the xml files and the integers are constant definitions. So in the java code you can reference certain Android interface elements using a function "findViewById( integerId )" and you can easily specify the id's through this auto-generate R.java class like this: findViewById(R.id.installerButtonOk) and you magically get the a reference to the magical "installlerButtonOk" from your Android interface.

    This means that when compiling the java classes of the project into a JAR file that will be used as an unity Android plugin (and be placed in the Assets/Plugins/Android/ folder), all the constant definitions used in that plugin code like this R.id.installerButtonOk will be replaced by their constant values at compile time (with 0x7f050001 or 0x7f050002 or 0x7f030005 or with whatever id the R class was generated at the momoent).

    Until now, everything is normal and ok. But when you add the android plugin to the unity project you also need to add the "res" folder containing the actual UI xml interface files and you can't add these to the JAR folder because they won't be correctly built in the final android build. After adding the xml files containing the UI of the android plugin we've just talked about all we have left to do is the final android build. This means that there is another android project generated by Unity in the background with all the necessary folders amongst which is also the magical "res" folder containing all the xml files with UI elements and the images from our installer android plugin.
    This ALSO means that upon building the R java class must be automatically re-generated and it will of-course re-generate the integer ids, which by an incredible luck they are always the same as the ones used in the installer plugin jar, as long as there is only ONE plugin embedding it's own "res" folders in the Unity project.

    As soon as there is another plugin (like TapJoy) that embeds his own "res" folder, the newly generated R java class containing the id's for their UI elements get mixed up. So one plugin ends up referencing another's elements or just returns null reference when doing "findViewById(R.id.myPreciousOkButton)".
    ==========================

    This problem affects ALL android plugins that try to embed their UI resources into the final unity android build. TapJoy is also affected by this! This issue sucks and I can't seem to find a good way around it.

    And I can't seem to stop blaming Android for it's crappy way of dealing with these UI interface ids. What if I want to have multiple libraries each having their own nice UI layout defined. I know that I can make the R.java class to be generated in a separate package (like com.plugin1.R) but it won't do much good because all the xml resource files still need to be in the same final "res" folder for when building the final android build and there WILL be collisions between the id's of some UI elements from plugin1 with other from the plugin2.

    I don't know if I've managed to explain myself but booooy it's a tough one. With this issue fixed, skies the limit to one the Android Builder tool could do.

    P.S. Yes, the above was just the short story not the long one. :D
     
    Last edited: Feb 16, 2012
    gkillz likes this.
  36. srrngames

    srrngames

    Joined:
    Jul 17, 2011
    Posts:
    11
    longer post coming soon, but i have a suggestion for improving the ABT: ignore .svn, .git, etc file extensions when copying from the res/ directory. I got the following error in Step #2 of the ABT's run that's really nbd to work around, but it'd make life easier :)

    Code (csharp):
    1.  
    2. Error in copyInstallerResFolders(...) -> couldn't copy the Installer res folder:
    3. /Users/srrngames/Projects/projectname/Temp/StagingArea/res/.svn/all-wcprops (Permission denied)
    4. Error! Android Builder failed in Step 2: copyInstallerResFolders(...)
     
  37. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    COOL! Thank you for the feedback! :) I will definitely look into it. It's weird that i hade .svn folders inside my Installer Eclipse project and it never gave a "Permission denied" error. Hmm...weird...

    ===========
    Good news here too!!! I've managed to find a way to SOLVE the major issues described in the earlier post!
    In short terms, the solution to ALL the android plugins that want to integrate into Unity their UI layouts and custom user interfaces from their "res" folders they:

    1) must NOT export their auto-generated R.java classes into the plugin JAR file. That's a BIG mistake when embedding into Unity. Unity will copy the contents of the plugin "res" folder if it's placed in the Assets/Plugins/Android/ folder, but when it will make the build, it will automatically re-generate the R.java class for the Unity project and map the user interface elements from the android plugin "res" folder to other id's different from the ones saved in the R.java class you exported the android plugin in the first place and calls like "findViewById(...) will return Null in the plugin).
    Note: The id's will be generated differently IF there is another plugin with it's own "res" folder. If not then the plugin is just lucky. But it's not ok.

    2) must ALWAYS set their android projects to generate the R.java class with NON-CONSTANT fields in the class. This is possible since Eclipse ADT 14 i think. This will help when exporting the jar because at compile time the constant definitions will NOT be replaced by the compiler with the direct values which will then lead to possible mixed references or loss of references to the UI elements of the plugin when the resource files get re-mapped.

    3) must ALWAYS set the package name of their R.java class to be the same as the one used in the Unity project. Unity doesn't know about generating different R.java classes for different pacakage names. It will just generate the R.java class for the Unity project package name (the bundle name of the project specified in the Build Settings). Also I couldn't find ANY way to make the android SDK build tools to map a different set of resources for one package of a R.java class, and another set of resources for another package. I don't think it's even possible. The Android SDK just bundles ALL the resource xml files in one binary resources.arsc file and maps them and maps their id's in one R.java class per project. If someone knows differently please try to explain it to me and tell me if it's possible otherwise. It will help me and many other people making android plugins for Unity a lot.

    The chase for the new release is back on! Uhuu! :D

    Hope this helps someone.
     
    Last edited: Feb 13, 2012
  38. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @floky, I just found this thread and have run into the exact issue that you are seeing. Currently there is no simple solution. Your plan of using library projects to get non-constant fields will work for projects where the source code is available and it is recompiled for each specific project with the main package name from Unity (definitely not an ideal situation). R15 will have support for distributing a full binary library which *should* remedy the situation assuming it actually works. The entire resource situation on Android is a complete mess IMO but that's a tale for another day...
     
  39. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hi there Prime31 buddy! :)
    Totally agree with you! Like I said Google has a made a mess with the Android design of handling UI layouts in my opinion and yes I talked an unofficial discussion with someone from Android (not allowed to give names) that said they're going to try and make this work somehow. But they also promised to offer a storage on the Android Market per app of 2 x 2GB data files to solve the APK size limitation and this was quite a while back and still no sign of anything.

    I also have a solution that I plan to release soon along with my next version of the plugin and will hopefully solve the issues that you are talking about so that other Unity android plugins won't have to share their project code to the user to re-build.

    The purpose of my Android Installer plugin is to allow the users to totally customize it. But for the TapJoy plugin or other similar plugins this solution I have will solve all these Android R.java class conflicts issues for Unity projects.
    Hope it will work, still have some small tests to do with it before applying and releasing it public but if it works, it will surely solve many android plugin conflicts and will also allow exporting of UI layouts for multiple android plugins in Unity.

    Happy Valentine's Day!
    Keep in touch! ;)

    [Edit 1]
    P.S. Hey Prime31 buddy! As soon as I finish implementing it, I'll send you a PM with the solution that can help us with making Unity android plugins coexist in peace and harmony. :D

    I will also upload the solution on the forum for anybody else. For how much? Don't be stupid, for free of course. ;)

    [Edit 2]
    Everything is going ok so far. I will finish the implementation and upload it this weekend. Stay tuned.
    Also the new version of the AndroidBuilder tool will use this solution to avoid issues with the UI of other android plugins. Will be uploading it this weekend also.
     
    Last edited: Feb 16, 2012
  40. kyocon

    kyocon

    Joined:
    Feb 16, 2012
    Posts:
    1
    im excited to use this with a new rpg me and my brother are going to develop

    where can i download the tool?

    thanks for making this free
     
  41. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
  42. srikanth.basappa

    srikanth.basappa

    Joined:
    Feb 16, 2012
    Posts:
    6
    Hello Floky,

    First off, awesome job on this project and it is very promising. It will definitely help out all the Unity(Android) developers out there involved in porting iOS games.

    I followed you steps and gotten it to level of splitting the final apk to two apks.

    Currently I am unable to launch the game when i install the apk named Installer. Following is the error log:

    02-16 14:29:28.132: D/Unity(3221): Mono path[0] = '/mnt/asec/com.companyname.gamename-1/pkg.apk/assets/bin/Data/Managed'
    02-16 14:29:28.140: E/mono(3221): The assembly mscorlib.dll was not found or could not be loaded.
    02-16 14:29:28.140: E/mono(3221): It should have been installed in the `/mnt/asec/com.companyname.gamename-1/pkg.apk/assets/bin/Data/Managed/mono/2.0/mscorlib.dll' directory.

    I have a bunch of logs in the InstallerActivity and it seems like its not even getting to onInstallerInit() :-o ...
    One more thing I have the "gamename" set in the manifest but it seems to be adding "-1" to the gamename. Is that an expected behavior ?

    Again, thanks a ton for spending your time on this project, it will indeed be very useful to this community :)

    your response will be much appreciated!
     
  43. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hi there! Something went wrong when packaging the Unity libraries in the APK. Don't understand yet why though.
    Please provide the Unity version you're using, the device model you tested on and send me a PM with the contents of your Assets/Plugins/Android folder together with the Unity app bundle name from your Player Settings. This info will help me further debug your problem easier.
    Also please send the Installer APK file you've generated with the android builder tool.

    Regarding the "-1" appended to the gamename, yes it's normal. It's not generated from my tool, the Android OS does that when installing apk files. Don't really know why. :D
     
  44. buffonomics

    buffonomics

    Joined:
    Jun 10, 2009
    Posts:
    59
    Waiting for the weekend floky. :p
    You da man.
     
  45. srikanth.basappa

    srikanth.basappa

    Joined:
    Feb 16, 2012
    Posts:
    6
    Thanks Floky!
    Thanks for replying. I figured out the issue. I didn't have some things in the manifest doh!.

    I am running into a issue with UI ids messed up with Tapjoy plugin in the R.java file.

    Hoping your fixes for these are working properly! Will wait for your next release.

    FYI: I was having issues with the tool in Step 2: with the .meta. I modified the Builder to nuke these files at the beginning... I do hear other ppl are having similar issues with other file .svn etc. But its a minor fix.

    Thanks!
     
  46. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    No problem. Thanks for your feedback. It helped me fix this issue. The tool will ignore svn hidden dirs or Mercurial or Git and so on. It will also ignore *.meta files.
    Today I will launch the new AndroidBuilder version, hopefully with all the discussed issues fixed. :)

    Regarding the TapJoy plugin I have managed to make my tool to not collide with UI ids from TapJoy or any other future android plugin.
    The issue still remains with TapJoy when another android plugin having it's own R.java class buit-in will be added to the same Unity project. The 2 plugins will have wrong UI ids.

    But the important thing is that the new AndroidBuilder will play nice with all the other android plugins and if you're not going to use other android plugins besides TapJoy, with built-in R.java classes in the plugin, everything should work ok for you, including TapJoy UI.

    As soon as I finish the separate R.java class fix I will post it for other plugins to use it in successfully adding their UI to a Unity project. But I don't think I have time to finish this one today as well.

    Cheers!
     
  47. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    New AndroidBuilder version news!

    Just finished testing the auto-update support for the Installer and it works great!
    Also did some more tests with the builder when having svn, cvs or any other versioning folders in the Installer "res" folder and everything is nice and error free.

    All that's left to do is update the instructions and get the package ready for upload. ;) Stay tuned!
     
  48. srikanth.basappa

    srikanth.basappa

    Joined:
    Feb 16, 2012
    Posts:
    6
    Great news!

    Again thanks for building this awesome tool.

    Will wait for your next update and let you know how it works for me ;)
     
  49. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Last edited: Feb 20, 2012
  50. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Awesome job floky! Thank you for all of your hard work. Are there any known issues with 3.5 or has anyone braver than I tried to make a build in 3.5? I plan on upgrading to 3.5 before deploying my next Android build (for bug fixes mainly) and I wonder if I should hold off if this tool doesn't work properly.