Adding ActonBarSherlock to Android Studio

I am trying to add an ActionBarSherlock to an existing application. It is not as easy as I thought. I have been doing this for two days now. I tried every tutorial for 2 pages of Google results. Here is what I got after this tutorial .

Structure of my project

enter image description here

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' 

dependencies

enter image description here

My mistake

enter image description here

I have done a lot of research and I can’t get it to work. I get an error every time, so I don’t understand something correctly. Please help. Thank you 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 causes an error:

 Gradle: Execution failed for task ':ClashMMA:processDebugManifest'. > Manifest merging failed. See console for more info. 
+6
source share
2 answers

I also struggled with this, as it seemed that every tutorial or answer that I followed left some small details that the beginner does not know how to automatically do something. Here's how I ended up adding ABS to my project:

1. Do not load ABS at all. You can completely add it by modifying the existing build.gradle file. Not your build.gradle project, but your internal folder, which is the parent folder of your src directory.

2. Open the SDK manager and make sure you have the Android SDK Build-tools 18.0.1 (later versions may also work).

3.Model the build.gradle file after mine. This is the exact build.gradle file that I use for this. 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 clicking the button:

enter image description here

+9
source

The author of ActionBarSherlock provided the .aar file, so you will no longer need to create the library in your libraries folder. You can change your build.gradle as 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 the dependencies and the removal of the library dependency. (I also see that your gradle is 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 with those who work with ABS for you).

Now you can safely remove your libraries / ActionBarSherlock that you no longer need, and change the settings.gradle file to:

 include ':ClashMMA' 

Hope this helps.

+3
source

Source: https://habr.com/ru/post/956972/


All Articles