虽然这是重复的,但是在我尝试了所有可用的解决方案后,我发布了这个。我实际上正在使用Connect sdk库,它应该是我当前项目的子项。 CastHelloText是我的项目& connect-SDK是库。 Gradle构建文件如下: -
Cast-Hello Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 10
targetSdkVersion 22
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
android.enforceUniquePackageName = false
}
dependencies {
compile 'com.connectsdk:connect-sdk-android:1.4.+'
compile project(':Connect-SDK-Android')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:mediarouter-v7:22.2.0'
compile 'com.google.android.gms:play-services-cast:7.5.0'
}
Connect-SDK gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'org.robolectric:robolectric-gradle-plugin:0.14.+'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
apply plugin: 'robolectric'
apply plugin: "jacoco"
jacoco {
toolVersion = "0.7.1.201405082137"
}
task jacocoTestReport(type:JacocoReport, dependsOn: "testDebug") {
group = "Reporting"
description = "Generate Jacoco coverage reports"
classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
additionalSourceDirs = files(android.sourceSets.main.java.srcDirs)
sourceDirectories = files(android.sourceSets.main.java.srcDirs)
executionData = files('build/jacoco/testDebug.exec')
reports {
xml.enabled = true
html.enabled = true
}
}
test.dependsOn jacocoTestReport
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [
'src',
'core/src',
'modules/google_cast/src'
]
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest {
java.srcDirs = [
'core/test/src',
'modules/google_cast/test/src'
]
}
}
buildTypes {
debug {
testCoverageEnabled = true
}
release {
minifyEnabled false
}
}
android.enforceUniquePackageName = false
}
robolectric {
include '**/*Test.class'
}
dependencies {
compile files('core/libs/java-websocket-patch.jar')
compile files('core/libs/javax.jmdns_3.4.1-patch2.jar')
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:mediarouter-v7:22.0.0'
compile 'com.google.android.gms:play-services-cast:7.5.0'
androidTestCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
androidTestCompile('junit:junit:4.+')
androidTestCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-plugin-registry'
exclude module: 'maven-profile'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'nekohtml'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-http-shared'
exclude module: 'wagon-provider-api'
exclude group: 'com.android.support', module: 'support-v4'
}
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'org.powermock:powermock-mockito-release-full:1.6.2'
}
Settings.gradle
include ':app', ':Connect-SDK-Android'
文件系统
答案 0 :(得分:0)
如果您没有看到AndroidStudio的构建与CLI ./gradlew构建相同的结果,请检查您的Studio设置...
如果AS配置为" gradle wrapper"并且您正在从" gradle"中调用AS / gradle。在极右侧控制栏中的图标,你使用相同的build.tasks,你应该得到相同的结果....