android - Android清洁架构示例程序

标签 android intellij-idea gradle

我正在关注http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/上的文章,并下载了示例git hub项目https://github.com/android10/Android-CleanArchitecture

该项目已使用gradle构建,因为我以前的项目是使用android的默认生成器构建的,所以我发现很难构建该项目。

我已经设置了gradle的环境。但是当我尝试在根文件夹上使用gradle build构建项目时,出现此错误。(注意:我使用Intellij作为我的IDE)

我首先在根文件夹中执行gradle构建,但收到此错误:

* Where:

构建文件'/ Users / magic / Desktop / android / myProjects / TestingProjects / Android Clean Architecture / Android-CleanArchitecture-master / data / build.gradle'行:1
  • 出了什么问题:

  • 评估项目':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


  • 尝试:

  • 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。

    建立失败

    因此,我转到了gradle文件夹,并将gradle-wrapper.properties更改为gradle-1.10-all.zip并进行了./gradlew构建,但出现了以下错误:
    FAILURE: Build failed with an exception.
    
  • 其中:
    构建文件'/ Users / Magic / Desktop / android / myProjects / TestingProjects / Android Clean Architecture / Android-CleanArchitecture-master / data / build.gradle'行:9
  • 出了什么问题:
    评估项目':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}.

  • 尝试:
    使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。

  • 建立失败

    及其指向第9行
     defaultConfig {
    applicationId "com.fernandocejas.android10.sample.data" //line 9
    minSdkVersion 15
    targetSdkVersion 19
    

    }

    非常感谢您对此的投入。

    谢谢。

    最佳答案

    我刚刚下载了该项目,将其导入Intellij 13.1(使用gradle包装器),它可以立即使用。您已经对破坏了它的build.gradle文件进行了更改。没有在这里发布所有gradle文件,很难说出问题是什么。指示gradle文件已被修改的一个迹象是,您给出的错误之一是:

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

    但是该示例未应用此插件,而是应用了正确的插件,即:
    apply plugin: 'com.android.library'
    

    再次尝试获取该项目,不要更改gradle构建文件。另外,请确保您使用的是gradle包装器,而不是您本地分发的gradle。

    我希望这有帮助!

    关于android - Android清洁架构示例程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26029113/

    相关文章:

    android - 使用应用程序上下文启动 Webview 时,未打开选择 html 组件(下拉列表)

    Android 布局对齐问题

    java - 在 IDEA 中打开项目时如何停止自动刷新 SBT 模块?

    intellij-idea - 有intellij模板语法引用吗?

    Android 注释未使用 buildToolsVersion 19.1.0 生成

    Android 12 待定意向

    javascript - 添加 1 - Javascript Android Studio

    android - 无法使用 IntelliJ IDEA 在 Android L 上访问 SQLite

    java - AAPT:错误:找不到属性 android:clipToOutline

    android - 无法将库添加到Android Studio中的项目