I am trying to add ActionBarSherlock to my existing app. This is not as easy as I thought. I have been doing this for two days now. I have tried every tutorial for 2 pages of Google results. Here is what I have after following this tutorial.
My project Structure
ActionBarSherlock/actionbarsherlock/ build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
ClashMMAProject/ClashMMA/ build.gradle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
setting.gradle
include ':ClashMMA', ':libraries:ActionBarSherlock:actionbarsherlock'
Dependancies
My Error
I have done a lot of research and I can't get anything to work. I get an error every time, so there is something I don't understand correctly. Please help. Thanks for your time.
Update
Ok after the suggestions, this is what I have in ClashMMAProject/ClashMMA/ build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
This is producing an error:
Gradle: Execution failed for task ':ClashMMA:processDebugManifest'.
> Manifest merging failed. See console for more info.
I also struggled with this, as it seemed every tutorial or answer I followed left some small detail out that a beginner doesn't know as something to automatically do. Here is how I eventually got ABS added to my project:
1.Don't download ABS at all. You can completely add it by modifying your existing build.gradle file. Not your project's build.gradle, but your inner folder that is the parent folder of your src directory.
2.Open SDK Manager and make sure you have Android SDK Build-tools 18.0.1 (later versions might also work).
3.Model your build.gradle file after mine. This is the exact build.gradle file I am using that works. Make sure your minSdk and targetSdk match what is in your manifest:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
4.Make sure you are using gradle 1.8 in gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
5.Sync project with gradle files by pressing the button:
The ActionBarSherlock author has provided a .aar file, so you will no longer need to build the library that you have in your libraries folder. You can change your build.gradle to be something like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Note the actionbarsherlock aar file in dependencies, and the removal of the library dependency. (I also see that your gradle is at 0.5.+ and your buildToolsVersion is at "17.0.0", the most recent versions are 0.6.+ and "18.1.1", but you can work on those once ABS is working for you).
Now you can safely remove your libraries/ActionBarSherlock, which you will no longer need, and change your settings.gradle file to:
include ':ClashMMA'
Hope this helps.
Related
I know there are similar questions like this but i'm new in android development and i need to learn how to import an example defining repositories and dependencies in the build.gradle project file.
After several tries i can't figure out which is the right way...
The example is this one https://github.com/neokree/MaterialNavigationDrawer
When i load the project in android studio i get an error "Configuration with name 'default' not found.", and it's ok.. i know that i have to modify the build.grandle file
repositories {
mavenCentral()
}
dependencies {
compile 'it.neokree:MaterialNavigationDrawer:1.3.3'
}
But where i have to add/replace these rows? In the buildscript area? in the allprojects? i get "Gradle DSL method not found: 'compile()'" error or fix plugin version alert if i try to change something.
original build.grandle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
Your problem is in setting.gradle file in the MaterialNavigationDrawer project. As you can see
include ':app', ':MaterialNavigationDrawerModule'
it requires MaterialNavigationDrawerModule project to build. Go to New > Import Module and import MaterialNavigationDrawerModule.
Update build.gradle in MaterialNavigationDrawer\app to
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "it.neokree.materialnavigationdrawer"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
//runProguard false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile project(':MaterialNavigationDrawerModule')
}
Update build.gradle in MaterialNavigationDrawer\MaterialNavigationDrawerModule to
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName 'dev'
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.balysv:material-ripple:1.0.1'
}
In MainActivity i deleted missing import
and rewrite Intent
to
Now it's working.
I have installed Android Studio (0.6.1) on OS X (10.9.3) and Gradle 1.1 using Brew (brew install gradle). However, I can't get my first Hello World! project... Please help me solve this issue
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {}
productFlavors {}
}
dependencies {
}
Error message:
Error:(8, 0) Plugin with id 'android' not found.
Getting Build failed with an Exception Android Studio 0.4.3 and 0.4.4 post and Android Studio: Plugin with id 'android-library' not found post does not solves the problem...
Second post I linked returns this error message:
Error:The project is using an unsupported version of Gradle. Please
use version 1.10. Please point to a supported Gradle version in the
project's Gradle settings or in the project's Gradle wrapper (if
applicable.) Fix Gradle wrapper and
re-import project Gradle settings
It seems you have missed to add android gradle plugin dependency in dependencies block.
Replace the top buildScript section by this and sync your project with gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'YOUR_APP_PACKAGE'
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors { }
}
dependencies {
}
build.gradle file inside my "app" folder: PATH: /home/work/ProjectName/app/build.gradle
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:+'
}
}
build.gradle file outside my "app" folder: PATH: /home/work/ProjectName/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Note after all these update synchronise your project with gradle file
Put below code in build.gradle file of main Application and sync it.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Credit to Ganesh Katikar
I'm been trying to add a jar in my Android Studio project.
I already edited my build.gradle :
dependencies {
compile files('/libs/capptain-sdk-android-2.2.0/capptain.jar')
}
The code works fine (it compile and I have what I want in my app) but when I look at my code I have a lot of errors from the resolver :
I think that I might have forgotten something somewhere to tell him that com.ubikod.capptain.android.sdk.activity.CapptainActivity exist. Any ideas ?
Edit:
Here are all my build files, the main one :
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
allprojects {
version = '1.0'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
}
apply plugin: 'android-reporting'
And the one specific for my module :
apply plugin: 'android-library'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile group:'com.google.code.gson', name:'gson', version:'2.2.4'
compile project(':libs:volley')
compile 'com.android.support:support-v4:18.0.0'
compile files('/libs/capptain-sdk-android-2.2.0/capptain.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.0"
defaultConfig {
versionCode 1
versionName '1.0'
minSdkVersion 15
targetSdkVersion 18
}
lintOptions {
abortOnError false
}
}
Thanks for your help!
I've referenced roboguice 2.0 in my new Android project build with Android Studio, here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile files('/libs/android-support-v4.jar')
compile 'org.roboguice:roboguice:2.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
}
}
Both gradle clean and gradle build run successfully but the IDE is reporting the error Element resources must be declared in roboguice.xml
Am I missing something or is this a bug in the IDE?
Mystery solved,
I've accidentally copied roboguice.xml to res/menu instead of res/values
I am having a problem to make my Android application build.
I have one Main application module, and another one that is needed for the google-play-services_lib.
My folder structure is as follows:
ParkingApp
|
|-----> google-play-services_lib (Library Project)
|-----> ParkingApp
|-----> settings.gradle
My settings.gradle file is as follows:
include ':ParkingApp', ':google-play-services_lib'
My ParkingApp has the following build.gradle.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
compile project(':google-play-services_lib')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
}
And the google-play-services_lib has the following build.gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/google-play-services.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Any help is appreciated!
With the new updates in Android Studio and Gradle, I think a better solution for adding support package and google play services jars is to use the maven repositories instead of adding the library it self, here is how you can add both to any .gradle file, using this way you will no have more problems adding both to dependent projects.
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:support-v4:13.0.+'
}
Note: In the new version of Android Studio 0.2.0, you will need also to update the gradle verison to:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
Put google-play-services.jar in MyParkingApp/libs and reference it as a dependency from MyParkingApp/build.gradle.