-1

I'm making a very simple mobile F2P arcade game in Unity After adding SDKs for facebook, gamesparks, firebase, and appodeal I coud not build, getting the "Too many method references: 76221; max is 65536" error.

The solution from Too many field references: 70613; max is 65536 is apparently to export an ADT project, import it into Android studio and go from there.

I built following these instructions, and after building my Android studio project had errors relating to the facebook SDK similar to here: Unity exporting android project with Facebook SDK issue

The solution proposed there is to copy all the .aar from your Unity project to files to the Android studio project and add lines to the build.gradle file referencing them, which I did.

After doing all that the 4 facebook related errors are gone but one new one appears:

Error: more than one library with package name 'android.support.v7.appcompat

A proposed solution for that is to search for the offending file and delete it in windows explorer but there is nothing with that name in my Android studio project folder. I tried removing some .aar files with appcompat in the name but I ended up reverting to the previous 4 facebook errors

It seems I can either have the 4 facebook errors or the 'more than one library' error.

Here is what my build.gradle file looks like..

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.3"

        defaultConfig {
            applicationId "com.ARTEFICER.fruitfall"
            minSdkVersion 16
            targetSdkVersion 25
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }

    dependencies {
        compile(name: 'animated-vector-drawable-23.4.0', ext: 'aar')
        compile(name: 'appcompat-v7-23.4.0', ext: 'aar')
        compile(name: 'cardview-v7-23.4.0', ext: 'aar')
        compile(name: 'customtabs-23.4.0', ext: 'aar')
        compile(name: 'facebook-android-sdk-4.17.0', ext: 'aar')
        compile(name: 'facebook-android-wrapper-7.9.4', ext: 'aar')
        compile(name: 'firebase-app-unity-3.0.3', ext: 'aar')
        compile(name: 'firebase-common-10.2.6', ext: 'aar')
        compile(name: 'firebase-iid-10.2.6', ext: 'aar')
        compile(name: 'firebase-messaging-10.2.6', ext: 'aar')
        compile(name: 'firebase-messaging-unity-3.0.3', ext: 'aar')
        compile(name: 'play-services-ads-10.2.6', ext: 'aar')
        compile(name: 'play-services-ads-lite-10.2.6', ext: 'aar')
        compile(name: 'play-services-base-10.2.6', ext: 'aar')
        compile(name: 'play-services-basement-10.2.6', ext: 'aar')
        compile(name: 'play-services-clearcut-10.2.6', ext: 'aar')
        compile(name: 'play-services-gass-10.2.6', ext: 'aar')
        compile(name: 'play-services-location-10.2.6', ext: 'aar')
        compile(name: 'play-services-tasks-10.2.6', ext: 'aar')
        compile(name: 'support-compat-25.2.0', ext: 'aar')
        compile(name: 'support-core-ui-25.2.0', ext: 'aar')
        compile(name: 'support-core-utils-25.2.0', ext: 'aar')
        compile(name: 'support-fragment-25.2.0', ext: 'aar')
        compile(name: 'support-media-compat-25.2.0', ext: 'aar')
        compile(name: 'support-v4-25.2.0', ext: 'aar')
        compile(name: 'support-vector-drawable-23.4.0', ext: 'aar')
        compile project(':animatedvectordrawable2340')
        compile project(':cardviewv72340')
        compile project(':cheetahmobile')
        compile project(':customtabs2340')
        compile project(':facebookandroidsdk4170')
        compile project(':facebookandroidwrapper794')
        compile project(':firebase')
        compile project(':firebaseappunity303')
        compile project(':firebasecommon1026')
        compile project(':firebaseiid1026')
        compile project(':firebasemessaging1026')
        compile project(':firebasemessagingunity303')
        compile project(':playservicesads1026')
        compile project(':playservicesadslite1026')
        compile project(':playservicesbase1026')
        compile project(':playservicesclearcut1026')
        compile project(':playservicesgass1026')
        compile project(':playserviceslocation1026')
        compile project(':playservicestasks1026')
        compile project(':supportcompat2520')
        compile project(':supportcoreui2520')
        compile project(':supportcoreutils2520')
        compile project(':supportfragment2520')
        compile project(':supportmediacompat2520')
        compile project(':supportv42520')
        compile project(':supportvectordrawable2340')
        compile 'com.google.android.gms:play-services:+'
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile files('libs/applovin-6.3.0.jar')
        compile files('libs/appodeal-1.15.9.jar')
        compile files('libs/bolts-android-1.4.0.jar')
        compile files('libs/bolts-applinks-1.4.0.jar')
        compile files('libs/bolts-tasks-1.4.0.jar')
        compile files('libs/chartboost-6.6.1.jar')
        compile files('libs/flurry-analytics-6.5.0.jar')
        compile files('libs/libmessaging_unity_player_activity.jar')
        compile files('libs/my-target-4.5.10.jar')
        compile files('libs/support-annotations-25.2.0.jar')
        compile files('libs/unity-ads-2.0.4.jar')
        compile files('libs/unity-classes.jar')
        compile files('libs/yandex-metrica-2.62.jar')
    }

    allprojects {
       repositories {
          jcenter()

          flatDir {
            dirs 'libs'
          }
       }
    }

I've tried commenting out these lines.

compile 'com.android.support:appcompat-v7:25.3.1'

compile project(':supportcompat2520')

compile(name: 'support-compat-25.2.0', ext: 'aar')

But I still have that one 'more than one library with package name' error

Also please note I am a Unity dev. I have never opened Android Studio until a few days ago, so you will certainly need to dumb things down as much as possible!

Guye Incognito
  • 2,726
  • 6
  • 38
  • 72
  • Maybe some of your dependencies has the appcompat lib inside, so you should exclude it , or at least import it just once – Jonathan Aste May 23 '17 at 14:39
  • I dont really understand your comment, but if delete appcompat-v7-23.4.0.aar and remove the reference to it in build.gradle, then I'm back to getting the 4 facebook errors again – Guye Incognito May 23 '17 at 14:44
  • You have two imports, compile(name: 'appcompat-v7-23.4.0', ext: 'aar') and compile 'com.android.support:appcompat-v7:25.3.1', I'm not sure, but that could be the problem. You are giving the compiler the same package twice. – Jonathan Aste May 23 '17 at 14:48
  • Yeah I did try removing those 3 lines above (which include the one you just mentioned) and it made no difference, still got that one 'more than one library with package name' error. If I remove this one compile(name: 'appcompat-v7-23.4.0', ext: 'aar'), then I'm back to the 4 facebook errors – Guye Incognito May 23 '17 at 15:23

2 Answers2

1

ADT is deprecated. The latest version of Unity supports gradle. When generating Android Project, build with the Gradle(New) otion and open the Project with Android Studio. Don't build with the ADT(Legacy) option. This will generate the right files for you and will likely get ride of the errors you have or reduce them.

enter image description here

Programmer
  • 121,791
  • 22
  • 236
  • 328
-1

I have not solved this. But I have bypassed it.

  1. Appodeal have another SDK package with less methods

  2. I removed parts of this appodeal SDK. They have libraries for each ad provider they use. I will un-register from the ad providers whose libraries I removed.

This way I was able to get the methods to under 65536, so I can build normally from Unity.

ps. Even if I had been able to get this export to work I would have left it in a branch, finished everything else, and merged it in at the end when I'm going to publish. It would have been untenable to work building this way as certain things (like facebook) will only work on device, so I normally build to device, say every hour.

Guye Incognito
  • 2,726
  • 6
  • 38
  • 72
  • This is not really an answer since the title of this question is about error when exporting your project and trying to open your project. If this is a question about the references error, then it is a [duplicate](https://stackoverflow.com/questions/42582850/too-many-field-references-70613-max-is-65536). – Programmer May 23 '17 at 17:44
  • Youve been doing a great job, following me around pointlessly hampering my efforts, without offering any help. Well done. Making SO what it is today. – Guye Incognito May 24 '17 at 15:08