Android Question Cannot compile anymore, dex problem.

Discussion in 'Android Questions' started by Nb1320, Jun 20, 2015.

  1. Nb1320

    Nb1320 Member Licensed User

    Code:
    B4A version: 5.02 (1)
    Parsing code.    (
    0.35s)
    Compiling code.    (
    0.60s)
    Compiling layouts code.    (
    0.15s)
    Generating R 
    file.    (0.08s)
    Compiling generated Java code.    (
    9.17s)
    Convert byte code - optimized dex.    Error
    trouble writing output: Too many field references: 
    66775max is 65536.
    You may 
    try using --multi-dex option.
    References by package:
         
    5 android.app
         
    7 android.content.pm
        
    19 android.graphics
         
    1 android.hardware
         
    6 android.os
         
    7 android.provider
         
    4 android.util
         
    3 android.view
       
    119 anywheresoftware.b4a
        
    25 anywheresoftware.b4a.agraham.reflection
        
    81 anywheresoftware.b4a.keywords
       
    125 anywheresoftware.b4a.keywords.constants
       
    188 anywheresoftware.b4a.objects
        
    13 anywheresoftware.b4a.objects.collections
        
    15 anywheresoftware.b4a.objects.drawable
         
    3 anywheresoftware.b4a.objects.streams
       
    172 anywheresoftware.b4a.phone
        
    70 anywheresoftware.b4a.randomaccessfile
       
    105 aurelienribon.tweenengine
        
    56 aurelienribon.tweenengine.equations
         
    2 aurelienribon.tweenengine.primitives
    65630 b4a.example
       
    101 com.rootsoft.tweenengine
         
    9 java.lang
         
    4 java.lang.annotation
         
    2 java.nio
         
    1 java.util
         
    2 java.util.concurrent

    This is what I am getting now when I try to compile my app, I have been working on it for a while so it is pretty big, but I have never seen this until today. I have looked into the multi-dex that it mentions, but I can't find anything that pertains to B4A and the issue. I REALLY hope this is an easy, quick fix. I appreciate any help! Thanks! :)
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

  3. Nb1320

    Nb1320 Member Licensed User

    Sorry, I should have mentioned that. That was the only thing I could find somewhat concerning the issue, I did increase it, but no change. Thanks though.
     
    RandomCoder likes this.
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Yeah, you have hit the android limit for dex symbols.
    You would need multidex support somehow.
     
    Nb1320 likes this.
  5. Nb1320

    Nb1320 Member Licensed User

    Code:
    Convert byte code - optimized dex.    Error
    trouble writing output: Too many field references: 
    66775max is 65536.
    thedesolatesoul, what can I do to make the number decrease. I can't understand what it is that controls this number. Lines of code, files, modules, there may be a way I can decrease whatever it is so that I can start working on it again. Thanks.
     
  6. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Nb1320 likes this.
  7. Nb1320

    Nb1320 Member Licensed User

    I read over that page before trying to figure something out, i'll look again and maybe come across something. Thanks for the help.
     
  8. Nb1320

    Nb1320 Member Licensed User

    Still having a problem with this, I just bought a new license to use the new version and now I can't find a way around this issue. I have tried everything I could think of, but nothing works. I will try to breakdown my problem.

    I am building an app that has A LOT of activity modules that each open there own designer made file. I have it setup like this because of the way that I understand statemanager to work. Is there a way to make one activity module work with multiple designer made files.

    Please excuse my bad pseudo code, not sure if its all correct or not, but that isn't my actual coding.


    If I could make this : "Activity,"LIST""

    Sub Activity_Pause(UserClosed As Boolean)

    StateManager.SaveState(Activity,"LIST")

    End Sub

    a designer file instead of the activity module, I think it would work, is this possible?

    Thank you for the help!



    Code:
    Sub Globals

        
    Dim MyMenu As AnimatedSlidingMenu
       
    End Sub


    Sub Activity_Resume
       
    Activity.LoadLayout("listdesignerfile")
       
        MyMenu.Initialize(
    Activity, Me, "Collection""Test""L"50dip400dipColors.Transparent, Null)
                   
        MyMenu.AddItem(Icon, 
    "List1"Colors.White, Colors.Transparent, 1)
        MyMenu.AddItem(
    Null"List2"Colors.White, Colors.Transparent, 2)
        MyMenu.AddItem(
    Null"List3"Colors.White, Colors.Transparent, 3)
        MyMenu.SetTitle(
    Colors.Transparent, Colors.White, Gravity.CENTER_HORIZONTAL, Null)
        MyMenu.OpenMenu(
    "Fade")

    End Sub


    Sub Activity_Resume

    StateManager.RestoreState(
    Activity,"LIST",0)

    End Sub


    Sub Activity_Pause(UserClosed As Boolean)

    StateManager.SaveState(
    Activity,"LIST")

    End Sub


    Sub Click(SelectedItem As Object)
                   
        
    If SelectedItem = 1 Then
            
    Activity.LoadLayout("listdesignerfile1")

        
    End If
        
    If SelectedItem = 2 Then
            
    Activity.LoadLayout("listdesignerfile2")

        
    End If
         
    If SelectedItem = 3 Then
            
    Activity.LoadLayout("listdesignerfile3")

        
    End If
       
    End Sub
     
  9. Nb1320

    Nb1320 Member Licensed User

    Guess I should mention that the only thing that statemanager is saving for me is checkboxes on each designer made file. :)
     
  10. Erel

    Erel Administrator Staff Member Licensed User

  11. Johnmcenroy

    Johnmcenroy Active Member Licensed User

    The same error.
    Code:
    trouble writing output: Too many field references: 69857max is 65536.
    Here https://developer.android.com/intl/ru/tools/building/multidex.html there is a solution
    to overcome this problem, but for gradle system. But there is a solution for ANT system also:
    1. Modify project build.xml file to support multidex. Here is an excellent modified build.xml file
    with all needed: https://github.com/ruboto/ruboto-irb/blob/master/build.xml

    OR

    modify ant.jar (DexExecTask with parameter for multidex)

    Also I saw that dexer.jar in B4A contains multidex classes.

    Then two steps from multidex support tutorial for gradle:
    2. Add to the project of B4A:
    Code:
    #AdditionalJar: C:\Android\extras\android\support\multidex\library\libs\android-support-multidex.jar
    Path - your path to this file according to Android SDK installation

    3. Modify manifest file:
    Code:
    <!-- MultiDex -->
    <
    application android:name="android.support.multidex.MultiDexApplication" />
    inside AddApplicationText tag.

    Also info about that: http://stackoverflow.com/questions/27903059/enable-multi-dex-option-in-ant-for-android

    But is this possible to solve part 1 in B4A ?
     
    Last edited: Nov 11, 2015
  12. Erel

    Erel Administrator Staff Member Licensed User

    I need to further investigate it.
     
  13. jotaele

    jotaele Member Licensed User

    Same problem.
     
  14. ValDog

    ValDog Active Member Licensed User

    I ran into this as well, and found a post which led me to strip down one of my libraries ("android-support-v4.jar") of functions that I was not using.
     
    jotaele likes this.
  15. jotaele

    jotaele Member Licensed User

    I do the same. Remove folders in the library jar files to decrease references.
     
  16. MarcoRome

    MarcoRome Expert Licensed User

    Hi Erel, hi all.
    More often I have this problem. If you working together some libraries (example: MsSql (Don), Google Maps, OkHttp, MSMaterialDrawer) is easily overcome the limit imposed 65536.
    Is need to find a solution.
    thanks
    Marco
     
    ihabsharaf likes this.
  17. Erel

    Erel Administrator Staff Member Licensed User

  18. MarcoRome

    MarcoRome Expert Licensed User

    Thank you for your reply Erel.
    I use the library Don manfred (this great library uses this mysql-connector-java-5.1.34-bin.jar). I must use this library because, okHttp CANT work in the same wifi with more multiuser (when okHttp and use two or more users connect to the same DB in the same wifi you can not work).
    I see your link, this is good solution if you need to solve the problem quickly. Isn't it better to find a solution that solves the problem ??
    Thank you again and goo year
    Great B4X ;)
    Marco
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    I never heard of such issue. I'm pretty sure that the problem is somewhere else. If you like start a new thread and I'll help you solve it.
     
    MarcoRome likes this.
  20. itgirl

    itgirl Active Member Licensed User

    That's is really a useful information but I don't think modifying the ant is a good idea but i think it would be great if we can use the first solution and use the build.xml
     
Loading...