如何在eclipse中使用gradle构建和运行android项目

时间:2015-07-05 21:12:22

标签: android eclipse gradle android-gradle gradle-eclipse

您好我在eclipse中使用gradle构建了一个Android应用程序。我总是使用gradle在命令行中构建项目。现在我尝试在Android设备模拟器上的eclipse中构建并运行它。在eclipse中我不知道如何使用gradle在android模拟器设备上运行它来构建项目。我需要帮助。 您可以在下面找到我的buil.gradle文件

apply plugin: 'android'


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':appcompat_v7')
    compile "org.igniterealtime.smack:smack-android:4.1.0-rc1"
    compile "org.igniterealtime.smack:smack-tcp:4.1.0-rc1"
    // optional features
    compile "org.igniterealtime.smack:smack-android-extensions:4.1.0-rc1"
}

repositories {
  maven {
    url 'https://oss.sonatype.org/content/repositories/snapshots'
  }
  mavenCentral()
}

android {


    lintOptions{
        abortOnError false
    }


    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

1 个答案:

答案 0 :(得分:0)

您是否尝试添加gradle eclipse插件

apply plugin: "eclipse"

然后通过调用

从build.gradle生成eclipse项目
gradle eclipse

您还应该安装&#34; Gradle IDE Pack&#34;来自eclipse市场(帮助 - &gt; Eclipse Marketplace ......)。

相关问题