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

Android Builder Tool

Discussion in 'Android' started by zalogic, Mar 23, 2012.

  1. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Android Builder Tool is a tool for Unity that allows you to quickly build your game for Android while it auto splits your final APK into a small Installer APK and a game data APK. It also allows you to easily sign the new generated APK. (Android LVL license not yet supported).

    The thread where all this discussion about this tool started and where the tool was born is here:
    http://forum.unity3d.com/threads/111220-How-did-Shadowgun-reduced-APK-to-6-MB
    It still contains precious information and workarounds for various things. If you have any questions, please search that thread.

    Legal notice:
    This tool is provided for free but you are NOT allowed to sell the tool even if you modify it. You can use/modify the tool to build commercial products.

    News And Updates
    The previous thread had an unsuitable title and also became rather bulky.
    I have made a new package release for the tool: v1.0.1. It's a rather minor release that just solves a few minor issues and was tested with Unity 3.5.

    Version 1.0.1 of the tool is available.

    What's new in version 1.0.1:
    - the Installer doesn't override the Unity Product Name string anymore (renamed the strings.xml to installer_strings.xml also renamed "app_name" to "installer_app_name")
    - added CustomUnityPlayerProxyActivity class that will auto-start the UnityLauncherActivity or the UnityLauncherNativeActivity (fixes some issues with Sony XPeria Play devices). Now the Installer uses this class to start the corresponding Unity launcher activity.
    - modified AndroidManifest.xml from Installer Template Project to use custom proxy activity
    - added Unity libs for Unity 3.5 (you need to link the one you need to the Installer eclipse project)
    - the Unity sample project using the tool was replaced with a version built with Unity 3.5

    Downloads:
    Version 1.0.1: AndroidBuilderTool v1.0.1
    Version 1.0b: AndroidBuilderTool v1.0b

    ==============================================
    If you have any feedback regarding the tool, don't hesitate to send me a PM or write it in this thread and I will get back to you as soon as I can.
    Anyone that has successfully used this tool, please help others out too. Help each other for a better community and for a better future. ;)

    For the next release I'm gonna try and integrate Google's XAPK system into the tool replacing my current simple Installer. If anyone manages to accomplish any useful modifications to the tool, please post a link to the modified sources so anyone can benefit from them. Sharing is carrying. ;)

    I will soon upload the sources of the tool to a public Mercurial repository and post the link here.

    Thank you for all your support and patience so far!
     
    Last edited: Aug 10, 2018
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Do I need to make my game read from asset bundles or anything to get this to work or is it a magic bullet solution that will take an existing 200mb+ project and split it up so it just works?
     
  3. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Floky: Cool I'm looking forward to the new version. I think I may need to transition my solution to the UnityProxyActivity. Right now I'm just manually launching based on the code in the proxy version.

    hippocoder: No, the goal of this project is to not use any asset bundles but rather the "standard" Resources.Load methods which are faster, use less memory, and take less time to transition from project to project. It's not as simple as adding a script to your project though. It requires a bit of work in order to get it working, but it is definitely worth it.
     
    Last edited: Mar 23, 2012
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I was thinking that if this was indeed a one click wonder on asset store, it'd be worth the $100 asking price :)

    So to be clear, I need to make small scenes and only use resources.load? what about if the resources are already included as part of a unity scene?
     
    zalogic likes this.
  5. j-robichaud

    j-robichaud

    Joined:
    Aug 26, 2010
    Posts:
    40
    It is possible to get the bundle code of the installed gamedata apk directly. It fixes a bug where the User would go in Android "Manage Applications", select the game and then press on "Clear data". It would then ask to re-download the data even thought it was still on the SD card.

    Just make sure to call the method after you set the path "gameDataFile".


    Code (csharp):
    1.     /**
    2.      * Checks if there was a previous version of this app already installed and returns it's version.
    3.      * If it doesn't find a previous version it returns 0.
    4.      * @return
    5.      */
    6.     public int getPreviousAppVersion() {
    7.         if ( gameDataFile.exists() )
    8.         {
    9.             try {
    10.                 PackageInfo pInfo = getPackageManager().getPackageArchiveInfo(gameDataFile.getAbsolutePath(), 0);
    11.                 return pInfo.versionCode;
    12.             } catch (Exception e) {
    13.                 Log.e("Installer", "Error while trying to get the version code for the saved app!");
    14.                 e.printStackTrace();
    15.             }
    16.         }
    17.         return 0;
    18.     }
     
  6. j-robichaud

    j-robichaud

    Joined:
    Aug 26, 2010
    Posts:
    40
    If a phone has no SD Card and plenty of space on the phone, the game data will not download. For most phones it makes sense but some recent phones have lot internal memory.

    Ex: The HTC Amaze has 16gb of internal memory with no SD Card bundled. http://www.htc.com/us/products/amaze4g-tmobile/#tech-specs

    If there is no SD Card, the installer maybe should ask the user if he wants to install it on the internal memory instead.
     
  7. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    Devices that do not come bundled with an SD card (or have support for SD card at all for that matter) does have an SD card file directory in its internal file storage. This is virtually an emulation of an SD card, so that applications may target this directory as an external storage media to store itself or its asset files. I have not tested the tool in this thread yet, but using Samsung Galaxy S2 with 16 gb internal memory and no additional SD card installed, I've made many apps that I've utilized Application.dataPath (etc.) in, and they've all stored their necessary data within the "sdcard" directory. I am not sure what will happen if I did insert an SD card, whether or not the path reference in Android would shift itself toward the physical SD card.
     
  8. j-robichaud

    j-robichaud

    Joined:
    Aug 26, 2010
    Posts:
    40
    Did not work with the HTC Amaze with the tool. Might be the implementation of the tool in this case. Here's the code in question:

    Code (csharp):
    1.     public static boolean isExternalStorageAvailable() {
    2.         if (Environment.MEDIA_MOUNTED.equals(Environment
    3.                 .getExternalStorageState())) {
    4.             // We can read and write the media
    5.             return true;
    6.         }
    7.  
    8.         return false;
    9.     }
     
    Last edited: Mar 24, 2012
  9. j-robichaud

    j-robichaud

    Joined:
    Aug 26, 2010
    Posts:
    40
    According to android's documentation it seems right: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

     
  10. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    The code in this tool is actually looking for the physical SD media, in which case yes, the installer should prompt the user if he would like to install it on the internal storage media (internal sdcard directory preferably) instead - or simply do so without prompting.
     
  11. jhhoward

    jhhoward

    Joined:
    Mar 2, 2012
    Posts:
    6
    Great work Floky! I'll be downloading this and checking it out. Glad to hear you got 3.5 working and fixed up the ProxyPlayer issues
     
  12. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    The code is correct according to Android SDK. The problem is with the manufacturer. The manufacturer can customize the OS kernel and other things behind it and some did not respect the standard, so this code actually returns the virtual external memory flash drive (meaning the internal one no your physical SD card) on an Samsung Galaxy, but on some devices although until now I didn't know of any, it could look directly for the physical external SD card, like on "HTC Amaze".
     
  13. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    This actually is just 4 steps setup solution to build you 200MB Unity project (with Resources.Load and NO asset bundles) into 2 separate APK files:
    - an Installer APK that will automatically detect the GPU of the device and look for the game data apk with the texture compression suited for it
    - an game data APK that will contain all the game assets.

    This solution does NOT require any change in your code to make this work. You just have to follow the setups steps correctly and have some basic knowledge of Android SDK and working with an Eclipse Android project.

    Regarding:
    "So to be clear, I need to make small scenes and only use resources.load? what about if the resources are already included as part of a unity scene?"
    No! :) You don't need to do anything special with your project. Resources can be linked in the scenes all you want. :)
     
  14. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Don't forget!

    The thread where all this discussion about this tool started and where the tool was born is here:
    http://forum.unity3d.com/threads/111220-How-did-Shadowgun-reduced-APK-to-6-MB

    It still contains precious information and workarounds for various things. If you have any questions, please search that thread first for answers. A lot of good people contributed with some great feedback there. ;)
     
  15. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    Google's Android SDK documentation states otherwise:
    If you check the link provided by jrobichaud you will see that the Installer actually looks for the "external storage" reported by the OS and not the physical SD card. It depends though on the customization of the OS from the manufacturer. (J2ME standard issues all over again :D )
    http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
     
  16. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    Yes, this is what I was referring to. ;-) This is an awesome tool, you deserve much credit and many thanks for creating it and making it available for people.
     
  17. Bllacky

    Bllacky

    Joined:
    Oct 7, 2011
    Posts:
    17
    Am I understanding correctly, this tool only works on OSX and not on Windows?
     
  18. j-robichaud

    j-robichaud

    Joined:
    Aug 26, 2010
    Posts:
    40
    OSX only for now. I believe Windows support is on the unwritten roadmap.
     
  19. Bllacky

    Bllacky

    Joined:
    Oct 7, 2011
    Posts:
    17
    Shame... we really needed this on Windows.
     
  20. HazeTI

    HazeTI

    Joined:
    Jan 12, 2012
    Posts:
    83
    Hmm, I have *a* version working on Windows but it did require me to modify Floky's tool. Also I'm still using Version 1.0b not 1.0.1.

    If interested I can provide the code to call the tool from a Unity editor script and explain how to modify Floky's tool. That should get you going, but I'd only advise this if you're desperate as I'm still working on it, don't have it completely up and running and can't guarantee anything.
     
  21. HazeTI

    HazeTI

    Joined:
    Jan 12, 2012
    Posts:
    83
  22. HazeTI

    HazeTI

    Joined:
    Jan 12, 2012
    Posts:
    83
    Thanks Ferazel, I managed to use your solution to download the split apk and launch our game.

    I will look at the the validation stuff to see if I can figure that out. As I'm as worried at not having it as you.


    Also I made some changes you may want to incorporate. I added a constant class with a boolean USING_FULL_PACKAGE. If this is set to true then I return true in expansionFilesDelivered and I call return super.getPackageCodePath(); in the UnityLauncherActivity. This means while this is set to true we can continue to use Unity's "build and run" functionality and only go through the splitting when it is required.

    Also, and I think this may due to the way I'm using it (I have this as a separate project and only export the /src as a jar into the unity plugin folder), I had to change this line in startDownloadServiceIfRequired in Google's DownloaderService

    From
    String packageName = serviceClass.getPackage().getName();

    To
    String packageName = context.getPackageName();
     
    Last edited: Mar 28, 2012
  23. Eric-Laberge

    Eric-Laberge

    Joined:
    Jan 20, 2011
    Posts:
    26
    Hello!

    We had a problem causing the game to crash with an error message on restore when it was swapped out from memory.

    Steps to reproduce:
    1. Launch the game (after download and installation)
    2. Leave the game with the Home button
    3. Fill the device memory enough that the game is swapped out
    4. Launch the game again
    5. It crashes with an error message

    I found out that the GAME_DATA_LOCAL_PATH var is lost, so I added code to the two UnityActivity wrappers to save and restore it.

    Code (csharp):
    1.     @Override
    2.     public void onSaveInstanceState(Bundle savedInstanceState) {
    3.         savedInstanceState.putString("GameDataLocalPath", InstallerBaseActivity.GAME_DATA_LOCAL_PATH);
    4.         super.onSaveInstanceState(savedInstanceState);
    5.     }
    6.    
    7.     @Override
    8.     public void onRestoreInstanceState(Bundle savedInstanceState) {
    9.         if (InstallerBaseActivity.GAME_DATA_LOCAL_PATH == null  savedInstanceState.containsKey("GameDataLocalPath") == true)
    10.             InstallerBaseActivity.GAME_DATA_LOCAL_PATH = savedInstanceState.getString("GameDataLocalPath");
    11.        
    12.         super.onRestoreInstanceState(savedInstanceState);
    13.     }
    14.        
    15.     @Override
    16.     protected void onCreate(Bundle savedInstanceState) {
    17.         if (InstallerBaseActivity.GAME_DATA_LOCAL_PATH == null  savedInstanceState.containsKey("GameDataLocalPath") == true)
    18.             InstallerBaseActivity.GAME_DATA_LOCAL_PATH = savedInstanceState.getString("GameDataLocalPath");
    19.        
    20.         super.onCreate(savedInstanceState);
    21.     }
    22.  
    There might be a better place to put this code (in InstallerBaseActivity, maybe?), I didn't investigate much after it worked there.
     
  24. chud575

    chud575

    Joined:
    Nov 19, 2010
    Posts:
    43
    Hi Guys,

    I'm having some problems integrating Tapjoy using this builder. Essentially what is happening is that we have two "intent.action.MAIN"s and "intent.category.LAUNCHER"s.

    If we remove the launcher from the Tapjoy code, then the game loads, downloads the package, and runs fine, but the moment we try to load a Tapjoy Banner ad, it crashes, however, the other Tapjoy functionality works (offer wall, featured ad). If we remove the Launcher from the customInstaller and leave the tap joy one, then it doesn't work at all. Also, if we leave them both on, then we get two icons in the install, and Tapjoy's banners still don't work

    Here is my manifest:

    Code (csharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.ayopagames.dungeoncrawlers"
    5.     android:installLocation="preferExternal"
    6.     android:versionCode="1"
    7.     android:versionName="1.0">
    8.     <supports-screens
    9.         android:smallScreens="true"
    10.         android:normalScreens="true"
    11.         android:largeScreens="true"
    12.         android:xlargeScreens="true"
    13.         android:anyDensity="true"/>
    14.  
    15.     <application
    16.         android:icon="@drawable/app_icon"
    17.         android:label="@string/app_name"
    18.         android:debuggable="true">
    19.        
    20.          <activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
    21.                   android:label="@string/app_name"
    22.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    23.                   <!-- MAIN/LAUNCHER duplicate from this section and the TapjoyPluginActivity was causing crashes -->
    24.                   <!-- <intent-filter>
    25.                     <action android:name="android.intent.action.MAIN" />
    26.                     <category android:name="android.intent.category.LAUNCHER" />
    27.                 </intent-filter> -->
    28.         </activity>
    29.         <activity android:name="com.unity3d.player.UnityPlayerActivity"
    30.                   android:label="@string/app_name"
    31.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    32.         </activity>
    33.         <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
    34.                   android:label="@string/app_name"
    35.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    36.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    37.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    38.         </activity>
    39.         <activity android:name="com.unity3d.player.VideoPlayer"
    40.                   android:label="@string/app_name"
    41.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    42.         </activity>
    43.        
    44.         <!-- Installer -->
    45.         <activity
    46.             android:name="com.userCustom.installer.InstallerActivity"
    47.             android:configChanges="keyboard|keyboardHidden|orientation"
    48.             android:screenOrientation="landscape">
    49.            
    50.             <intent-filter >
    51.                 <action android:name="android.intent.action.MAIN" />
    52.                 <category android:name="android.intent.category.LAUNCHER" />
    53.             </intent-filter>
    54.         </activity>
    55.  
    56.         <activity android:name="com.flk.unityLauncher.CustomUnityPlayerProxyActivity"
    57.                   android:screenOrientation="landscape"
    58.                   android:configChanges="keyboard|keyboardHidden|orientation">
    59.         </activity>
    60.  
    61.         <activity android:name="com.flk.unityLauncher.UnityLauncherActivity"
    62.                   android:screenOrientation="landscape"
    63.                   android:configChanges="keyboard|keyboardHidden|orientation">
    64.         </activity>
    65.        
    66.         <activity android:name="com.flk.unityLauncher.UnityLauncherNativeActivity"
    67.                   android:screenOrientation="landscape"
    68.                   android:configChanges="keyboard|keyboardHidden|orientation">
    69.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    70.         </activity>
    71.         <!-- /Installer -->
    72.        
    73.         <!-- Tapjoy -->
    74.         <activity android:name="com.tapjoy.tapjoyPlugin.TapjoyPluginActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation"
    75.             android:screenOrientation="landscape">
    76.             <intent-filter>
    77.                 <action android:name="android.intent.action.MAIN" />
    78.                 <category android:name="android.intent.category.LAUNCHER" />
    79.             </intent-filter>
    80.         </activity>
    81.        
    82.         <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name"
    83.             android:configChanges="keyboardHidden|orientation">
    84.         </activity>
    85.        
    86.         <activity android:name="com.tapjoy.TJCOffersWebView" android:configChanges="keyboardHidden|orientation" />
    87.         <activity android:name="com.tapjoy.TapjoyFeaturedAppWebView" android:configChanges="keyboardHidden|orientation" />
    88.         <activity android:name="com.tapjoy.TapjoyVideoView" android:configChanges="keyboardHidden|orientation" />
    89.         <!-- /Tapjoy -->
    90.        
    91.         <!-- ACTIVITIES -->
    92.  
    93.         <!-- META-DATA -->
    94.         <service android:name="com.prime31.billing.BillingService" />
    95.         <receiver android:name="com.prime31.billing.BillingReceiver">
    96.         <intent-filter>
    97.         <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
    98.         <action android:name="com.android.vending.billing.RESPONSE_CODE" />
    99.         <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
    100.         </intent-filter>
    101.         </receiver>
    102.  
    103.     </application>
    104.    
    105.     <!-- PERMISSIONS -->
    106.     <uses-permission android:name="android.permission.INTERNET" />
    107.     <uses-permission android:name="com.android.vending.BILLING" />
    108.    
    109.     <!-- Installer -->
    110.     <uses-permission android:name="android.permission.WAKE_LOCK"/>
    111.        
    112.     <!-- Tapjoy -->
    113.     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    114.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    115.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    116.    
    117.     <uses-feature android:glEsVersion="0x00010001" />
    118.    
    119. </manifest>
    120.  
    any help with this will be greatly appreciated. Thanks guys.
     
  25. srrngames

    srrngames

    Joined:
    Jul 17, 2011
    Posts:
    11
    Hello again, team! We launched an app with this tool recently, and have been working out some issues. I should find some time to upload some of the changes we made ;)

    We're currently tracking an issue with some Samsung devices - the Epic 4G Touch Galaxy SII both claim they can't find the game data files to download. I'll keep everyone posted when we hopefully get some logs from the affected users.

    Thanks again to all contributors :)
     
  26. ZowPac

    ZowPac

    Joined:
    Sep 25, 2009
    Posts:
    58
    Great work on this tool!

    I do have another report for you of an issue with a Samsung device - this one is a Samsung Infuse (Firmware 2.2.1), which downloads the full game on every launch... we'll just send the user a standalone apk for now, but would be very interested if anyone has a work-around...
     
  27. dcariola

    dcariola

    Joined:
    Jul 13, 2011
    Posts:
    7
    I'm in the same issue with my InApp Billing pluging, as I needed to override the main Activity with my own. This issue will probably happen if using any plugin that require this behaviour. Do you know if is there a straight forward solution or I should integrate the plugin init to the installer activity?
     
  28. gharaibeh

    gharaibeh

    Joined:
    Apr 26, 2011
    Posts:
    115
    after install app and while downloading finish he show this message

    Sorry!
    The application TemplateInstaller(Process com.unityInstaller.template ) has stopped unexpectedly .Please try again.
     
  29. Bllacky

    Bllacky

    Joined:
    Oct 7, 2011
    Posts:
    17
    We now have the same problem. The tool used to work great about a month ago.

    It looks like there was an incompatibility between the gameData and the installer. The problem has been fixed now.
     
    Last edited: May 18, 2012
  30. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Hi. Wanted to know if there is a windows version of this tool yet. Would be very awesome and I'm excited to try it out, but don't have access to a Mac yet :(
     
  31. Belforg

    Belforg

    Joined:
    Jun 5, 2012
    Posts:
    1
    I'm having some problems implementing this with Unity 3.4...

    At the Android Builder Tool, when I try to split the apk, an error appears at step 1 related to the 2 items it tries to copy (splash.png and settings.xml), I've found app_splash.png and AndroidManifest.xml in the StagingArea folder. I've renamed and copied them (although I don't think that is the good way to solve this), but at step 3 the folder gen inside StagingArea folder is missing too...

    Any thoughts on why it can't find those files and folders?

    Edit: I've found the problem. For anyone else with the same problem, the Mac was having some issues with permissions. Just rebuild the game in another folder and BAM, it can walk!
     
    Last edited: Jun 7, 2012
  32. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    Wth people on Macs can make this for Android development but not windows?

    I'm at 48mb on my build size and not nearly done and this appears to be a nightmare to implement for the average person. Goddamnit. Android pisses me off so much, between fragmented market and this. Mac has high cost of entry, ugh.

    /frustrated

    Also since assetbundles are Pro only, is there any way to split the APK with android and Unity basic???????????
     
    Last edited: Jun 11, 2012
  33. selzero

    selzero

    Joined:
    Dec 3, 2009
    Posts:
    32
    I am having a problem with this, my game streams videos from the streaming assets folder, it seems that the eventual activity set up in the manifest file kicks out the activity that lets me play videos within my android game.

    * EDIT *

    It seems the problem is a small design flaw in the way the engine exposes the video player activity. We have coded a work around, Floky if you want to add it to your solution PM me.
     
    Last edited: Jun 19, 2012
  34. junglemason

    junglemason

    Joined:
    Dec 30, 2010
    Posts:
    69
    I am encountering an error during the post process build phase. The installer builder throws these errors:

    Code (csharp):
    1. UNEXPECTED TOP-LEVEL EXCEPTION:
    2. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R$attr;
    3. [ etc ]
    4.  
    5. UNEXPECTED TOP-LEVEL EXCEPTION:
    6. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R$drawable;
    7. [ etc ]
    8.  
    9. UNEXPECTED TOP-LEVEL EXCEPTION:
    10. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R$id;
    11. [ etc ]
    12.  
    13. UNEXPECTED TOP-LEVEL EXCEPTION:
    14. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R$layout;
    15. [ etc ]
    16.  
    17. UNEXPECTED TOP-LEVEL EXCEPTION:
    18. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R$string;
    19. [ etc ]
    20.  
    21. UNEXPECTED TOP-LEVEL EXCEPTION:
    22. java.lang.IllegalArgumentException: already added: Lcom/mycompanyname/mygamename/R;
    23. [ etc ]
    24.  
    25. 6 errors; aborting
    26. Error while trying to generate DEX file!
    27. Error! Android Builder failed in Step 4: generateDexFile()
    EDIT:
    I was exporting the whole project as a jar and I needed to only export the src folder. My derp.
     
    Last edited: Jun 28, 2012
  35. junglemason

    junglemason

    Joined:
    Dec 30, 2010
    Posts:
    69
    Is it possible to use custom fonts in the installer screen? It looks like the answer might be "no", since the installer builder only asks for the "res" folder and not the "assets" folder. But let me know if my assumption is wrong.

    Thanks for your work on this, floky!
     
  36. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    I'm new with this. How can I change getGameDataUrl method to use google play app hosting? I can't host files on my own server.

    Thanks ;)
     
  37. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Anyone alive on this post?

    I'm having a problem. App downloads well the data apk from our server but after that crash. Here's the log, hope someone can help me:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gametopia.clippox/com.flk.unityLauncher.UnityLauncherNativeActivity}: java.lang.RuntimeException: unable to link library
    E/AndroidRuntime(31796): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
    E/AndroidRuntime(31796): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    E/AndroidRuntime(31796): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    E/AndroidRuntime(31796): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    E/AndroidRuntime(31796): at android.os.Handler.dispatchMessage(Handler.java:99)
    E/AndroidRuntime(31796): at android.os.Looper.loop(Looper.java:138)
    E/AndroidRuntime(31796): at android.app.ActivityThread.main(ActivityThread.java:3701)
    E/AndroidRuntime(31796): at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(31796): at java.lang.reflect.Method.invoke(Method.java:507)
    E/AndroidRuntime(31796): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
    E/AndroidRuntime(31796): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
    E/AndroidRuntime(31796): at dalvik.system.NativeStart.main(Native Method)
    E/AndroidRuntime(31796): Caused by: java.lang.RuntimeException: unable to link library
    E/AndroidRuntime(31796): at java.lang.Runtime.nativeLoad(Native Method)
    E/AndroidRuntime(31796): at java.lang.Runtime.loadLibrary(Runtime.java:432)
    E/AndroidRuntime(31796): at java.lang.System.loadLibrary(System.java:554)
    E/AndroidRuntime(31796): at com.unity3d.player.UnityPlayer.<init>(Unknown Source)
    E/AndroidRuntime(31796): at com.unity3d.player.UnityPlayerNativeActivity.onCreate(Unknown Source)
    E/AndroidRuntime(31796): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    E/AndroidRuntime(31796): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    E/AndroidRuntime(31796): ... 11 more
     
  38. junglemason

    junglemason

    Joined:
    Dec 30, 2010
    Posts:
    69
    I'm also running into this using the Prime31 IAB plugin. The installer works fine, but then I am told that my app doesn't have billing enabled. I checked the manifest, and it's there. What else should I try?
     
  39. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Please, could someone help me? Download works well but I get that unable to start activity error.
     
  40. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Just a thought, but can you check your android manifest to make sure that it includes the native library that the NativePlayerActivity needs to link to? Your Manifest.xml entry for the player activity should look something like this with special attention to the <meta-data> tags.

    Code (csharp):
    1.  
    2. <activity android:name=".UnityLauncherNativeActivity"
    3.                   android:label="@string/app_name"
    4.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    5.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    6.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    7.         </activity>
    8.  
     
  41. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    My current manifest includes only:

    <meta-data android:name="android.app.lib_name" android:value="unity" />

    I've added the ForwardNativeEventsToDalvik line. I'll test it tomorrow as I don't have an android device right now. Thanks!
     
  42. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Still having problems, here's my Manifest code. Same on Eclipse Project and Unity Plugins/Android folder:


    Code (csharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.gametopia.clippox"
    5.     android:installLocation="auto"
    6.     android:versionCode="1"
    7.     android:versionName="1.0">
    8.    
    9.     <uses-sdk android:minSdkVersion="7"/>
    10.    
    11.     <supports-screens
    12.         android:smallScreens="true"
    13.         android:normalScreens="true"
    14.         android:largeScreens="true"
    15.         android:xlargeScreens="true"
    16.         android:anyDensity="true"/>
    17.    
    18.     <application
    19.         android:hardwareAccelerated="true">
    20.        
    21.         <activity
    22.             android:name="com.userCustom.installer.InstallerActivity"
    23.             android:configChanges="keyboard|keyboardHidden|orientation"
    24.             android:screenOrientation="landscape">
    25.             <intent-filter >
    26.                 <action android:name="android.intent.action.MAIN" />
    27.                 <category android:name="android.intent.category.LAUNCHER" />
    28.             </intent-filter>
    29.         </activity>
    30.  
    31.         <activity android:name="com.flk.unityLauncher.CustomUnityPlayerProxyActivity"
    32.                   android:screenOrientation="landscape"
    33.                   android:configChanges="keyboard|keyboardHidden|orientation">
    34.         </activity>
    35.  
    36.         <activity android:name="com.flk.unityLauncher.UnityLauncherActivity"
    37.                   android:screenOrientation="landscape"
    38.                   android:configChanges="keyboard|keyboardHidden|orientation">
    39.         </activity>
    40.        
    41.         <activity android:name="com.flk.unityLauncher.UnityLauncherNativeActivity"
    42.                   android:screenOrientation="landscape"
    43.                   android:configChanges="keyboard|keyboardHidden|orientation">
    44.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    45.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    46.            
    47.         </activity>
    48.  
    49.         <activity android:name="com.unity3d.player.VideoPlayer"
    50.                   android:configChanges="keyboardHidden|orientation">
    51.         </activity>
    52.        
    53.        
    54.  
    55.  
    56.         <!-- ACTIVITIES -->
    57.  
    58.         <!-- META-DATA -->
    59.  
    60.     </application>
    61.  
    62.     <!-- PERMISSIONS -->
    63.     <uses-permission android:name="android.permission.INTERNET"/>
    64.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    65.     <uses-permission android:name="android.permission.WAKE_LOCK"/>
    66.  
    67.  
    68. </manifest>
    I also get an error on Eclipse project: The import com.unity3d.player.UnityPlayerActivity is never used.
     
  43. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    I'll pay if needed for a fix. Android Builder author seems disappeared and we want to release our game. Here`s more info from log:

    Code (csharp):
    1. onGameCanStart() called!
    2. D/Installer(26673): Loading game from: /mnt/sdcard/Android/data/com.gametopia.clippox/files/gameData.apk
    3. D/Installer(26673): Closing the Installer activity...
    4. I/ActivityManager( 1791): Starting: Intent { cmp=com.gametopia.clippox/com.flk.unityLauncher.CustomUnityPlayerProxyActivity } from pid 26673
    5. I/ActivityManager( 1791): Starting: Intent { flg=0x10000 cmp=com.gametopia.clippox/com.flk.unityLauncher.UnityLauncherNativeActivity } from pid 26673
    6. D/dalvikvm(26673): Trying to load lib /data/data/com.gametopia.clippox/lib/libmono.so 0x4051cb78
    7. D/dalvikvm(26673): Added shared lib /data/data/com.gametopia.clippox/lib/libmono.so 0x4051cb78
    8. W/dalvikvm(26673): JNI_OnLoad returned bad version (0) in /data/data/com.gametopia.clippox/lib/libmono.so 0x4051cb78
    9. D/AndroidRuntime(26673): Shutting down VM
    10. W/dalvikvm(26673): threadid=1: thread exiting with uncaught exception (group=0x4001d578)
    11. E/AndroidRuntime(26673): FATAL EXCEPTION: main
    12. E/AndroidRuntime(26673): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gametopia.clippox/com.flk.unityLauncher.UnityLauncherNativeActivity}: java.lang.RuntimeException: unable to link library
    13. E/AndroidRuntime(26673):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
    14. E/AndroidRuntime(26673):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    15. E/AndroidRuntime(26673):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    16. E/AndroidRuntime(26673):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    17. E/AndroidRuntime(26673):    at android.os.Handler.dispatchMessage(Handler.java:99)
    18. E/AndroidRuntime(26673):    at android.os.Looper.loop(Looper.java:138)
    19. E/AndroidRuntime(26673):    at android.app.ActivityThread.main(ActivityThread.java:3701)
    20. E/AndroidRuntime(26673):    at java.lang.reflect.Method.invokeNative(Native Method)
    21. E/AndroidRuntime(26673):    at java.lang.reflect.Method.invoke(Method.java:507)
    22. E/AndroidRuntime(26673):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
    23. E/AndroidRuntime(26673):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
    24. E/AndroidRuntime(26673):    at dalvik.system.NativeStart.main(Native Method)
    25. E/AndroidRuntime(26673): Caused by: java.lang.RuntimeException: unable to link library
    26. E/AndroidRuntime(26673):    at java.lang.Runtime.nativeLoad(Native Method)
    27. E/AndroidRuntime(26673):    at java.lang.Runtime.loadLibrary(Runtime.java:432)
    28. E/AndroidRuntime(26673):    at java.lang.System.loadLibrary(System.java:554)
    29. E/AndroidRuntime(26673):    at com.unity3d.player.UnityPlayer.<init>(Unknown Source)
    30. E/AndroidRuntime(26673):    at com.unity3d.player.UnityPlayerNativeActivity.onCreate(Unknown Source)
    31. E/AndroidRuntime(26673):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    32. E/AndroidRuntime(26673):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    33. E/AndroidRuntime(26673):    ... 11 more
    34. W/ActivityManager( 1791):   Force finishing activity com.gametopia.clippox/com.flk.unityLauncher.UnityLauncherNativeActivity
     
  44. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    That manifest seems to match what I have. Granted I don't use the installer activity that is included with the floky installer, but then concept is virtually the same. The only other thing I can think of at the moment is to see if you imported the classes.jar from your version of Unity (expand the Unity.app bundle > PlaybackEngines > AndroidPlayer > bin > classes.jar) rather than the one that is included in the installer? Maybe there is some conflict there?
     
  45. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    I'm using the classes.jar file included with the installer. What does: "JNI_OnLoad returned bad version" mean?
     
  46. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    If you haven't already, can you try to use the classes.jar from the Unity bundle rather than the one that was in the installer?
     
  47. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    I'm still getting the same error.

    Just to check some things:

    - Exported from src folder .jar file is included on Unity project inside Plugins/Android folder no? Does it's name matters?
    - Eclipse shows a warning: "The import com.unity3d.player.UnityPlayerActivity is never used" Is that normal?
     
  48. Abza1989

    Abza1989

    Joined:
    Jul 17, 2012
    Posts:
    47
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Luk/co/urenco/Urenco/R$attr;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:95)

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Luk/co/urenco/Urenco/R$drawable;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:95)

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Luk/co/urenco/Urenco/R$string;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:95)

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Luk/co/urenco/Urenco/R;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:95)
    4 errors; aborting
    Error while trying to generate DEX file!
    Error! Android Builder failed in Step 4: generateDexFile()

    First of all thanks flokly! this was such a helpful tool! exactly what i need!

    but just implemented this Tool in my project, and got this error while the tool was building. Any ideas?

    Abz
     
  49. Abza1989

    Abza1989

    Joined:
    Jul 17, 2012
    Posts:
    47
    Hi can someone post a tutorial on how to set this up??

    Thanks
     
  50. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Yes please, step by step tutorial, docs included with the tool are horrible.