chkm8 chkm8 - 28 days ago 17
Android Question

Android-clean architecture sample program

I'm following an article from http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/ and downloaded the sample git hub project https://github.com/android10/Android-CleanArchitecture.

The project has been build using gradle, since my previous projects was build using the default builder of android, i found this hard building the project.

I already set up the environment of the gradle. but when I tried to build the project using gradle build on the root folder i get this error.(NOTE: Im using Intellij as my IDE)

I first performed gradle build in the root folder but received this error:

* Where:


Build file '/Users/magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/data/build.gradle' line: 1


  • What went wrong:



A problem occurred evaluating project ':data'.


Failed to apply plugin [id 'android-library']

Gradle version 1.10 is required. Current version is 2.1. If using the gradle wrapper, try editing the distributionUrl in /Users/magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip



  • Try:



Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

So, i went to folder gradle and change the gradle-wrapper.properties to gradle-1.10-all.zip and perfomed ./gradlew build but got this error:

FAILURE: Build failed with an exception.



  • Where:
    Build file '/Users/Magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/data/build.gradle' line: 9

  • What went wrong:
    A problem occurred evaluating project ':data'.


    Could not find method applicationId() for arguments [com.fernandocejas.android10.sample.data] on ProductFlavorDsl_Decorated{name=main, minSdkVersion=-1, targetSdkVersion=-1, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=-1, versionName=null, packageName=null, testPackageName=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.



BUILD FAILED

and its pointing to line 9

defaultConfig {
applicationId "com.fernandocejas.android10.sample.data" //line 9
minSdkVersion 15
targetSdkVersion 19


}

I would really appreciate your inputs with this.

Thanks.

Answer

I just downloaded that project, imported it into Intellij 13.1 (using the gradle wrapper), and it worked out of the box. You have made changes to the build.gradle files that have broken it. It is hard to say what the issue is without all your gradle files posted here. One indication that the gradle files have been modified is that one of the errors you gave was:

Failed to apply plugin [id 'android-library']

But the example does not apply this plugin, it applies the correct one, i.e.:

apply plugin: 'com.android.library'

Try getting that project again and don't change the gradle build files. Also make sure you are importing with the gradle wrapper, and not your local distribution of gradle.

I hope this helps!

Comments