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?
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.+'
}
}
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!
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.
Related
I didn’t work full-time with Android in the last couple of years, and now whenever I try to fork someone code on GitHub I get a lot of errors since android tools and Gradle syntax are changing frequently.
I wonder what is the best way to handle these changes, and be able to upgrade other GitHub projects and some of my old projects to work with the latest Android tools. Here are some of the things that I struggle with:
I noticed some of the issues are related to changes in the Gradle syntax. How can I know what Gradle version the build.grade syntax was written with? and then how to upgrade it to the current version (is there a migration guide for Gradle versions?).
Sometimes I get issues related to tools that are not compatible with others, how can I know which version are compatible with which? and whats the easy way to manage that? here are some of these tools:
Gradle
Android Plugin for Gradle
Build Tools
Android Studio
How can I know what Gradle version the build.grade syntax was written with?
If the project contains a gradle/wrapper/gradle-wrapper.properties file, that is the version of Gradle that the developer of the project is using.
is there a migration guide for Gradle versions?
I am not aware of much Gradle syntax that would have changed that would affect Android developers for garden-variety projects. Most of the changes are from the DSL added via the Gradle for Android plugin. You can find the version of the plugin that the project developer was using via the classpath statement in the project's top-level build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
The above snippet is requesting version 1.3.0 of the Gradle for Android plugin.
Migration documentation for the Gradle for Android plugin is minimal. What there is can be found up on http://tools.android.com.
how can I know which version are compatible with which?
Here is Google's statement on the issue, though this has not been updated in a few months.
and whats the easy way to manage that?
If the tools complain, change them to a set that you know is good (e.g., by copying values from a known-working project). If you need something that was introduced in a newer version of the tools, change them to a set that you know is good. Otherwise, don't worry about them.
I am a beginner for Android Cloud Endpoints. I am trying to create a backend module in Android Studio 1.0 RC2. Everything seems okay while creating a backend endpoint module (https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints). The gradle builds successfully. But when I wanted to debug locally, I found the problem. It said, "App Engine Gradle configuration not detected on module, maybe you need to Sync Project with Gradle".
I tried to rebuild the whole project, it builds successfully. But the error remains.
This is the screenshot: https://www.dropbox.com/s/tvuv52ldmr0yzvs/Screen%20Shot%202014-11-27%20at%204.21.14%20pm.png?dl=0
Thank a lot.
This was a recently introduced bug that has since been fixed in Android Studio 1.0.
I am not sure if it is the solution. But this is what I did. I created another new project (the problem happened in existing project that I migrated from Android Studio 0.8.9 to 1.0 RC2. I added new module for Google Cloud EndPoints. Initially it was same problem (there is same error in debug config as above, although it can build the whole project successfully.) But after I changed the build.gradle file in backend module to gradle-appengine-plugin:1.9.17 (latest), the new project backend was okay.
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
}
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.17'
compile 'com.google.appengine:appengine-endpoints:1.9.17'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.17'
compile 'javax.servlet:servlet-api:2.5' }
I tried to change the build.gradle file in my migrated projects, but still failed. So, what I did was copy the content from new project
backend.iml
file into my migrated project backend.iml. And it works.
i'm working with android studio and i have an issue... i import 2 libraries (facebook SDK and Aws) that both use and import the android support v4 libs, doing that gradle can't compile anything giving a bad top-level exception (dexDebug).
In others answer i saw that i can solve this situation in 2 ways, removing one of the libs (but i can't because i need both) or using the "multipledex = true" in build.gradle that give me another error for the length of the command.
So, what i should do? Shall i stop using AS and go back to Eclipse? Or anybody have a solution?
Thanks,
Andrea
Don't import the support library by copying its jar as you used to in Eclipse. In Gradle, access it via its Maven coordinates and the build system will ensure that only one copy gets linked into your project:
dependencies {
compile 'com.android.support:support-v4:X.X.X'
}
where X.X.X is the right version number for your SDK installation. If you manage the dependency via Project Structure > (your module) > Dependencies > + > Library dependency it will help you get the version number right.
When I run the installClientLibs from Android Studio (with gradle command as well) for an Endpoint, the jar is generated with this name:
libEndpoint-v1-1.18.0-rc-SNAPSHOT
But since some days ago, it's being generated as:
libEndpoint-v1-1.19.0-SNAPSHOT
Where do the "18.0-rc" and the "19.0" come from? Why did it change? Is it due to a SDK update maybe?
This is the version of the Google libraries:
google-api-client-1.18.0-rc
google-api-client-android-1.18.0-rc
google-http-client-1.18.0-rc
google-http-client-android-1.18.0-rc
google-oauth-client-1.18.0-rc
These libraries are used to generate android client library for your Android module.
You can see them if you expand External Libraries section in Android Studio.
You can also check what is the latest version in Maven Repository. Just go to http://search.maven.org/ and type one of them. You will notice that 1.19.0 is the newest one as you posted.
If you would like avoid update Android module gradle file every time version changes, you can set your dependency like this:
compile project(path: ':backend', configuration: 'android-endpoints')
where backend is the name of the module. By the way, this is how Google Cloud Endpoint template generates configuration for a while. If you find any difficulties applying this way, try creating new project and generate backend module.
I'm using Android Studio with an external Android SDK. I have installed the support library and the support repository. The support repository is in:
~/Development/Tools/android/sdk/extras/android/m2repository
When I add a dependency to the support library in the build.gradle file, like:
...
repositories {
mavenCentral()
}
...
dependencies {
compile "com.android.support:support-v4:18.0.+"
}
Android Studio cannot find the support libraries (cannot resolve symbol etc) and Gradle also cannot find the libraries:
Gradle: A problem occurred configuring project ':TestAndroidStudio'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':TestAndroidStudio:_DebugCompile'.
> Could not find any version that matches com.android.support:support-v4:18.0.+.
Required by:
TestAndroidStudio:TestAndroidStudio:unspecified
How do I specify in Android Studio and/or the build.gradle file the location of the Android support repository?
You are probably hit by this bug which prevents the Android Gradle Plugin from automatically adding the "Android Support Repository" to the list of Gradle repositories. The work-around, as mentioned in the bug report, is to explicitly add the m2repository directory as a local Maven directory in the top-level build.gradle file as follows:
allprojects {
repositories {
// Work around https://code.google.com/p/android/issues/detail?id=69270.
def androidHome = System.getenv("ANDROID_HOME")
maven {
url "$androidHome/extras/android/m2repository/"
}
}
}
Gradle can work with the 18.0.+ notation, it however now depends on the new support repository which is now bundled with the SDK.
Open the SDK manager and immediately under Extras the first option is "Android Support Repository" and install it
Found a solution.
1) Go to where your SDK is located that android studio/eclipse is using.
If you are using Android studio, go to extras\android\m2repository\com\android\support\.
If you are using eclipse, go to \extras\android\support\
2) See what folders you have, for me I had gridlayout-v7, support-v4 and support-v13.
3) click into support-v4 and see what number the following folder is, mine was named 13.0
Since you are using "com.android.support:support-v4:18.0.+", change this to reflect what version you have, for example I have support-v4 so first part v4 stays the same. Since the next path is 13.0, change your 18.0 to:
"com.android.support:support-v4:13.0.+"
This worked for me, hope it helps!
Update:
I noticed I had android studio set up with the wrong SDK which is why originally had difficulty updating! The path should be C:\Users\Username\AppData\Local\Android\android-sdk\extras\
Also note, if your SDK is up to date, the code will be:
"com.android.support:support-v4:19.0.+"
Android Studio 3
Make sure you have the latest version of Android Studio. The support library is included by default when you create new projects. If you are adding the Support Library to a project that doesn't have it, then you just need to add a single line to your app module's build.gradle file, and then sync gradle.
build.gradle
dependencies {
...
implementation 'com.android.support:appcompat-v7:27.1.1'
}
It should just be that easy, though there may be some things to note:
Android Studio should give you a warning nowadays if the support library needs to be updated. Just update the 27.1.1 numbers that I have here to whatever it tells you to. You can also manually check what the latest revision is if you want to.
The implementation keyword replaces compile that was used in Android Studio 2.x. (What's the difference?)
There are other support library packages that you may need to include depending on what your app uses (like constraint-layout or recyclerview).
Make sure that you have the latest updates for everything in the SDK Manager. Go to Tools > SDK Manager.
Documentation
Support Library
Support Library Setup
Support Library Features
I used to get similar issues. Even after installing the support repository, the build used to fail.
Basically the issues is due to the way the version number of the jar files are specified in the gradle files are specified properly.
For example, in my case i had set it as "compile 'com.android.support:support-v4:21.0.3+'"
On removing "+" the build was sucessful!!
Instead of doing this:
compile "com.android.support:support-v4:18.0.+"
Do this:
compile 'com.android.support:support-v4:18.0.+'
Worked for me