Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "Could not find method bundle() for arguments [build_6plat21h.....] on object of type com.android.build.gradle.LibraryExtension"?

Alright I submit, I am trying to get a Unity 3D project working in a View on Android and it seems easy enough thanks to some tutorials online. However, I am stuck at the part where I need to convert the unity project to a module/AAR file. When following steps on these online tutorials, I get to the stage where I need to sync the gradle project and I receive:

ERROR: Could not find method bundle() for arguments [build_6plat2lh5rmq66u2k9bfvj0j1$_run_closure3$_closure12@655df9f] on object of type com.android.build.gradle.LibraryExtension.

The steps I used to produce the issue:

On Unity:

  • I have set up a basic 3D animation
  • Go to build settings

    • set texture compression: ETC2 > build system: Gradle > check: Export project
    • Set package name
  • Click Export

  • Select a folder for the library

Android Studio

  • File -> New -> Import Module -> Select project that was exported from Unity
  • Project opens -> "Gradle settings are not configured for this project yet, would you like to use the Gradle Wrapper" -> Select "Ok"
  • In build.gradle
    • Remove applicationID (as instructed by android docs)
    • Change apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
  • Sync gradle project

Where I found these steps:

  • https://medium.com/@davidbeloosesky/embedded-unity-within-android-app-7061f4f473a and a couple of similar medium tutorials
  • https://developer.android.com/studio/projects/android-library

Version Info

  • Gradle version: 4.10.1
  • Android plugin version: 3.3.0
  • Gradle wrapper properties distributionURL:
    https://services.gradle.org/distributions/gradle-4.10.1-all.zip

[EDIT] I forgot to mention that I removed [below] from the manifest

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
like image 416
Daniel Hignell Avatar asked Jan 17 '19 10:01

Daniel Hignell


2 Answers

I ran into the same problem trying all things, commenting the bundle block fixed the problem for me

/*bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }*/

I am not sure if this is the right approach but after building the project and generating the apk I got my .aar file which I guess is what you are trying to get.

like image 147
Luis_RH Avatar answered Nov 15 '22 11:11

Luis_RH


I ran into the same issue. To solve this, you need to change apply plugin: 'com.android.application' to apply plugin: 'com.android.library' and delete applicationID in both build.gradle as there are two.

like image 21
user11091673 Avatar answered Nov 15 '22 13:11

user11091673