编译两个应用程序,但只运行一个带有Android Studio的模块

时间:2015-11-27 10:29:42

标签: android-studio android-gradle

我有两个Android项目' East' &安培; ' ChoosePDF'在Eclipse中。 '东'是主要的应用程序,另一个是PDF文件库。

我尝试将它们从Eclipse导出到Android Studio。 当我试图运行东方'模块,设备中安装了两个应用程序。 ' ChoosePDF'也作为应用程序安装,应该只作为库来编译。

在应用管理中'设置,它显示为一个应用程序。但在设备的桌面上,这些是两个相同的图标。

这是项目的build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
        }
   }

项目的settings.gradle是:

include ':ChoosePDF'
include ':East'

这是模块' East的build.gradle,它是Eclipse中的主要项目。

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':ChoosePDF')
}

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.2"

    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')
    }
}

这是依赖库的build.gradle。

apply plugin: 'com.android.library'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 19
    buildToolsVersion "23.0.2"

    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')
    }
}

我真的不知道它是怎么发生的。尝试发表评论&#39; ChoosePDF&#39;在settings.gradle中,不起作用。尝试删除“ChoosePDF的build.gradle”中的内容,不起作用。

真的需要帮助来解决它,谢谢。

0 个答案:

没有答案