我试图在this教程中将Google+注册/登录集成到Android Studio中导入的旧版(Eclipse)项目中。在导入build.gradle文件时,我被卡住了。在实现Google +登录时在build.gradle中重复输入
错误说:
Error:Execution failed for task ':Study Story:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelperKitkat$1.class
我不能到调试的这种错误的原因。内水平的build.gradle文件有以下代码:
import java.util.regex.Pattern
apply plugin: 'android'
apply plugin: 'com.github.triplet.play'
apply from: 'signingRelease.gradle'
apply plugin: 'signing'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 15//lower than 14 doesn't support multidex
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
// For blurring images
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
buildTypes{
release {
signingConfig signingConfigs.publishApkRelease
}
debug {
signingConfig signingConfigs.debug
}
}
play {
track = 'beta'
serviceAccountEmail = '[email protected]account.com'
pk12File = file('keyfile.p12')
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude module: 'support-annotations'
}
repositories {
jcenter()
}
lintOptions {
abortOnError false
}
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')
}
}
dependencies {
compile project(':Viewpage:viewpage-library')
compile project(':CountryPicker')
compile project(':numberpicker-library')
compile('com.facebook.android:facebook-android-sdk:4.13.0') {
exclude module: 'bolts-android'
exclude module: 'support-v4'
}
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.parse.bolts:bolts-android:1.+'
//compile 'com.parse:parse-android:1.11.0'
compile 'com.parse:parse-android:1.+'
//compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-auth:9.0.0'
// glide is added to load the g+ profile image. Ignore if you want
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services-maps:9.0.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.+'
compile 'com.shamanland:fab:0.0.6'
//compile 'com.parse.bolts:bolts-android:1.1.+'
//compile fileTree(include: 'Parse-*.jar', dir: 'libs')
// compile fileTree(include: ['ParseFacebookUtilsV4-1.9.2.jar'], dir: 'libs')
compile fileTree(include: ['jsoup-1.7.3.jar'], dir: 'libs')
compile fileTree(include: ['ParseFacebookUtilsV4-1.10.3.jar'], dir: 'libs')
// compile fileTree(include: ['libGoogleAnalyticsServices.jar'], dir: 'libs')
//compile fileTree(dir: 'libs', include: ['android-support-multidex.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.traex.rippleeffect:library:1.3'
//SwipyRefreshLayout
compile 'com.github.orangegangsters:swipy:[email protected]'
// compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile('com.android.support:cardview-v7:23.2.0') {
force = true
}
}
apply plugin: 'com.google.gms.google-services'
/*
This is not working yet.
*/
task('increaseVersionCode') << {
println('in increaseVersionCode')
def manifestFile = file("AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def manifestText = manifestFile.getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def versionCode = Integer.parseInt(matcher.group(1))
println('in increaseVersionCode ' + versionCode)
def manifestContent = matcher.replaceAll("versionCode=\"" + ++versionCode + "\"")
manifestFile.write(manifestContent)
}
task('incrementVersionName') << {
println('in incrementVeriosnName')
def manifestFile = file("AndroidManifest.xml")
def patternVersionNumber = Pattern.compile("versionName=\"(\\d+)\\.(\\d+)\\.(\\d+)\"")
def manifestText = manifestFile.getText()
def matcherVersionNumber = patternVersionNumber.matcher(manifestText)
matcherVersionNumber.find()
def majorVersion = Integer.parseInt(matcherVersionNumber.group(1))
def minorVersion = Integer.parseInt(matcherVersionNumber.group(2))
def buildVersion = Integer.parseInt(matcherVersionNumber.group(3))
def mNextVersionName = majorVersion + "." + minorVersion + "." + (buildVersion + 1)
println('Major Version ' + majorVersion)
println('Minor Version ' + minorVersion)
println('Build Version ' + buildVersion)
def manifestContent = matcherVersionNumber.replaceAll("versionName=\"" + mNextVersionName + "\"")
manifestFile.write(manifestContent)
}
//Activate this if you wish for Gradle to handle the build number increments.
/*
tasks.whenTaskAdded { task ->
println('When task is added: ' + task.name)
if (task.name == 'generateDebugBuildConfig') {
// println('IN IFSTATMENTWITH : ' + task.name)
task.dependsOn 'increaseVersionCode'
task.dependsOn 'incrementVersionName'
}
}*/
项目级别(外)的build.gradle具有下面的代码:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.github.triplet.gradle:play-publisher:1.1.4'
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
//classpath 'com.google.gms:google-services:1.4.0-beta3'
}
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
}
allprojects {
repositories {
jcenter()
}
}
的文件夹结构看起来像下面图像:
请指出我需要修改以解决问题的区域。
检查此http://计算器。 com/questions/35156072/android-errorexecution-failed-for-task-transformclasseswithjarmergingfordeb – Shailesh
这对我不起作用,我已经尝试过了。 – kittu88