4

I'm new to Android Studio and i want to implement Urban Airship in one of my projects. I followed the example on their website with the .aar file and I ended up getting this error.

Error: [/Users/AndroidstudioProjects/MyApplication/app/build/intermediates/exploded-aar/com.urbanairship/urbanairship-lib/5.1.0/AndroidManifest.xml:8]
Invalid instruction 'overrideLibrary', valid instructions are : REMOVE,REPLACE,STRICT

Correct me if I'm wrong but doesn't this mean that they have issues in their manifest file? Or am I completely out in the blue? If so, do anyone have a good example on how to implement it?

soulkito
  • 236
  • 2
  • 13
  • Could be, android versions change so fast. Try the REPLACE option instead? I'm sure the code itself is probably fine. – G_V Nov 10 '14 at 13:31
  • 1
    Yeah sure but the file referred to in this log is part of urbanairship-lib and not my manifest. Making changes to a file under /build/ gets overwritten on next build right? – soulkito Nov 10 '14 at 13:35
  • 1
    Ah yeah, in that case you can probably only either file a ticket with them or get the source and compile it yourself – G_V Nov 10 '14 at 13:39
  • 1
    Sent them a ticket. And recompiling the code feels unnecessary for something that should be working out of the box. I guess that's my only solution of their support doesn't give me a better option. Thanks anyway! – soulkito Nov 10 '14 at 13:57
  • 1
    I have the same issue. Did they reply to your ticket? – jul Nov 10 '14 at 19:39
  • Yeah I got a reply today! You do apparently need to use Gradle plugin version 13.3 or greater to make it compile as stated in the other answers. It sure fixed my issues. – soulkito Nov 14 '14 at 08:36

3 Answers3

5

The Urban Airship SDK builds against Google Play Services that requires Android API 9, while Urban Airship is compatible with 6+. That is why we need the override library version. What android gradle plugin version are you using? You need to use 13.3 or greater. See http://tools.android.com/tech-docs/new-build-system.

In the projects build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.+'
    }
}
ralepinski
  • 1,756
  • 8
  • 15
1

I just had the same problem, and was able to fix it and build my project:

The offending line is line 8 of the AndroidManifest.xml I just removed this line and changed some SDK versions.

You can open the file urbanairship-lib-5.1.0.aar using WinRar. Navigate to the Manifest. Open it and edit within your favourite text editor. Save and close the manifest. WinRar asks if you want to update the archive. Choose Yes!

According to this page, overrideLibrary is used for when you have minSDK version in a library > minSDK version in your project. So it allows a different version to be compiled instead, without errors.

http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:overrideLibrary-marker

Remove, replace etc do something a bit different (also described on that page - scroll up).

Then in my projects build.gradle file I changed the version numbers to match my project:

From this

compile 'com.android.support:support-v4:21.+'

To this

compile 'com.android.support:support-v4:19.+'

Would be good to know what's the outcome of the OP's support ticket. Please keep us posted!

RudebwaiG
  • 11
  • 1
  • How would you do this in OS X? – Matthew Reilly Nov 13 '14 at 07:10
  • 1
    Try changing the extension of the .aar to .zip. Then open and modify the file as above, save the new zip and then rename back to aar. Also, please DON'T do the final step in my post above. It will help the project build, but then it will crash any time a push is received. Instead, use v4:21.0.0 not v:21.+ which may pick up the RC support package and disallow lower build targets. I didn't realise this at the time :s – RudebwaiG Nov 13 '14 at 10:17
  • Fantastic, could you update your answer to modify to show that? I almost ignored it because I'm relying on some of the v4:21 features so I didn't think I would be able to implement your solution. – Gabriel Nov 13 '14 at 19:55
  • UA Android SDK 5.1 requires v21, you will get a crash when a push is received if you force an older version. It is required to support the latest features in Android Lollipop. Unpacking and patching the manifest to remove the override library bits should mostly work, but I would not recommend it. 'overrideLibrary' was introduced in Android gradle plugin 0.13.3, and is now the only way to accomplish allowing an older min sdk then one of the dependencies. – ralepinski Nov 14 '14 at 17:02
0

I ran into this issue as well evaluating the 5.1.0 version of the Urban Airship SDK. I am using Android Studio Beta 0.8.14. I contacted Urban Airship support and they told me to increment the version of gradle to 0.13.3. Android Studio 0.8.14 is defaulting to 0.13.2. After changing the version of gradle to 0.13.3 in the project build.gradle file I was able to successfully compile and import the new SDK.