Android Studio同时为同一项目构建两个应用程序 [英] Android Studio builds two applications for the same project simultaenously

查看:1823
本文介绍了Android Studio同时为同一项目构建两个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio v0.5.9制作应用程序,该版本有一个库项目作为依赖关系。但是,每次运行该项目时,两个具有相同名称和图标的端口部署到我的设备上。第一个apk(app)包含我的主要模块,而第二个是图书馆项目本身。然而,当我从Eclipse运行相同的项目时,只有一个apk被部署,它的工作正常。



这里是一些截图的问题 -





第一个应用程序(我的模块) -





第二个应用程序(图书馆项目) -





顶级 build.gradle 文件 -

  buildscript {
repositories {
mavenCentral()
}
依赖关系{
classpath'com.android.tools.build:gradle:0.9.2'

//注意:不要将应用程序依赖关系放在这里;它们属于
//在单个模块中build.gradle文件
}
}

allprojects {
repositories {
mavenCentral()
}
}

主模块 build.gradle 文件 -

 应用插件:'android'

android {
compileSdkVersion 19
buildToolsVersion '19 .0.3'
defaultConfig {
packageName'com.Swap.Rooms'
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName'1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard- rules.pro'
}
}
productFlavors {
}
}

依赖关系{
编译fileTree(dir: libs',include:['* .jar'])
compile'c​​om.android。支持:support-v4:19.0.1'
compile'c​​om.android.support:appcompat-v7:19.0.1'
compile'c​​om.android.support:appcompat-v7:19.+'
编译项目(':lib')
}

库项目 build.gradle 文件 -

 应用插件:'android-library'

android {
compileSdkVersion 19
buildToolsVersion19.0.3

defaultConfig {
packageNamecom.jfeinstein.jazzyviewpager
minSdkVersion 4
targetSdkVersion 17
}

buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt') ,'proguard-rules.txt'
}
}
}

依赖关系{
编译'com.android.support:support-v4:+ '
编译文件('libs / nineoldandroids-2.4.0.jar')
}

settings.gradle -

  include':app'
包含':lib'

请帮我解决这个问题。感谢提前!!

解决方案

也许这对他人有帮助。



毕业也是图书馆项目的明显合并。所以问题是从库中保持 AndroidManifes.xml 不变。它有应用程序节点用于演示目的,并且此节点已成功合并到主要的 AndroidManifest.xml



我会将问题提交给Google,因为我认为应该防止或警告这种情况。


I'm making an app using Android Studio v0.5.9, which has a library project as a dependency. But, every time I run the project two apks having the same name and icon, are deployed to my device. The first apk(app) contains my main module, whereas, the second one is the library project itself. However, when I run the same project from Eclipse, only one apk is deployed and it works perfectly.

Here are some screenshots of the problem -

First App(My module) -

Second App(library project) -

top-level build.gradle file -

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

main module build.gradle file -

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'
    defaultConfig {
        packageName 'com.Swap.Rooms'
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.android.support:appcompat-v7:19.0.1'
    compile 'com.android.support:appcompat-v7:19.+'
    compile project(':lib')
}

library project build.gradle file -

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        packageName "com.jfeinstein.jazzyviewpager"
        minSdkVersion 4
        targetSdkVersion 17
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:+'
    compile files('libs/nineoldandroids-2.4.0.jar')
}

settings.gradle -

include ':app'
include ':lib'

Please help me to fix this. Thanks in advance!!

解决方案

Maybe this will be helpful for others.

Gradle is doing manifest merge for library projects as well. So issue was to keep AndroidManifes.xml unchanged from library. It had application node for demo purposes and this node was successfully merged to main AndroidManifest.xml.

I'm going to submit issue to Google since I think it should prevent or warn about such situation.

这篇关于Android Studio同时为同一项目构建两个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆