2

I'm a starter at android developing and am currently really stuck with implementing actionbarsherlock. I know this has been discussed before, but I'm getting really confused regarding dependencies and how to set up the project structure. I tried following all the instructions, but it's not working out. I keep getting a different problem with the gradle. I'm using Android Studio 0.2.0.

My current error says:

>Gradle 'MyAppProject' project refresh failed: >Could not fetch model of type 'IdeaProject' using Gradle distribution "http://services.gradle.org/distributions/gradle-1.6-bin.zip". >Error: Gradle: A problem occurred configuring project ':MyApp'. >Failed to notify project evaluation listener. >A problem occurred configuring project ':Libraries:ActionBarSherlock'. >Failed to notify project evaluation listener. >Main Manifest missing from C:\Users\JJ2\AndroidStudioProjects\MyAppProject\Libraries\ActionBarSherlock\src\main\AndroidManifest.xml 

My project is build as follows:

-MyAppProject |+.idea |+gradle |-Libraries ||-ActionBarSherlock |||+gen |||+libs |||+res |||-src ||||-android.support.v4.app |||||-Watson ||||+com.actionbarsherlock |||-ActionBarSherlock.iml |||-AndroidManifest.xml |||-build.gradle |||-lint.xml |||-pom.xml |||-project.properties |||-README.md |-MyApp ||+build ||+libs ||-src |||-main ||||-java |||||+com.mywebsite.myapp ||||+res ||||-AndroidManifest.xml ||||-ic_launcher-web.png ||-build.gradle ||-MyApp.iml |-build.gradle |-gradlew |-gradlew.bat |-local.properties |-settings.gradle |-MyAppProject.iml -External Libraries |-<Android 4.2.2> ||+android.jar ||+annotations.jar ||+res 

The content of the build.gradle in the MyAppProject directory:

task assemble{} 

The build.gradle in the MyApp directory:

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.0' } } apply plugin: 'android' dependencies { compile project(":Libraries:ActionBarSherlock") } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 9 targetSdkVersion 17 } } 

And the build.gradle in the Libraries\ActionBarSherlock directory:

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.0' } } apply plugin: 'android-library' dependencies { compile files('libs/android-support-v4.jar') } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 9 targetSdkVersion 17 } } 

Lastly, my Project Structure looks as follows:

Modules

-ActionBarSherlock (Dependencies: Android 4.2.2, [v]android-support-v4) -Android -MyApp (Dependencies: Android 4.2.2, [ ]ActionBarSherlock) -Android -Android-Gradle -MyAppProject (Dependencies: Android 4.2.2) -Android-Gradle 

Libraries

None 

Global Libraries

-android-support-v4 (Classes: ...\MyAppProject\MyApp\libs\android-support-v4.jar) 

I hope somebody can notice anything wrong with the code, although a lot of people seem to have uresolved issues since the new Android Studio release. Thanks in advance!

1 Answer 1

3

Top directory settings.gradle:

include ':MyApp', ':Libraries:ActionBarSherlock' 

include any other libs you may enter to your project

Top directory build.gradle: its okay with task assemble {}

Actionbar sherlock build.gradle

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android-library' dependencies { compile 'com.android.support:support-v4:13.0.0' } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 16 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('tests') } } 

Also, IN ALL .gradle files that gradle version is set: replace everywhere the gradle version to:

classpath 'com.android.tools.build:gradle:0.5.+' 

Android Studio 2.x uses gradle 0.5.x, and by using + you 'll keep your gradle up to date (they updated it before 2 days, and we have frequent updates!! )

Your gradle settings now will be okay! Note1: Any other erros may occur from iml./idea files ... You can try changing them in Studio's project settings, eg set source files for each module(sherlock, MyApp), their libraries, etc!

Note 2: Also if you are using some other libraries, which requires higher version of SDK than your app, you can get an error, w/o explanation!

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks a lot for your reply! I forgot to include the settings.gradle content, which was like you described. The other remarks were probably necessary indeed. Unfortunately, I started messing with the Project Settings->Gradle and now I keep getting an error message saying: Gradle 'WallPainterProject' project refresh failed: Could not install Gradle distribution from 'services.gradle.org/distributions/gradle-1.6-bin.zip'. Gradle distribution 'C:\Users\JJ2\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok' contains too many directories. Expected to find exactly 1 directory.
I can't seem to find an example of a proper set up for the gradle properties. I would be very grateful if you, or someone else, could post an example of a normal set up and of the directory where the gradle is located. And I would give you a +1, but I haven't collected enough karma myself yet haha.
you are welcome! To have a normal setup, just create an new empty project, with the .gradle changes i posted above. I faced some problems with gradle installation(it didnt completely download the gradle binaries)... I went to that directory you wrote, and deleted some lock and corrupted files! Go here: services.gradle.org/distributions/gradle-1.6-bin.zip, download it, and go to the gradle1.6-bin/72 ..../ directory, and then paste it, and extract it! Does it work now?
Well I just deleted everything and reinstalled android studio, and now the gradle errors are gone:). However, I'm getting a 'install parse failed inconsistent certificates' error, when I try to run the app on my phone, even though I already deleted the app from there. Any thoughts?
Well apparently the app was not in the app drawer anymore, but still in settings->apps. Anyway, I did everything you told me to and it all worked out! Thank again!!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.