Recently I'm trying to use LeakCanary to fix OOM(out of memory) issues for my Android app. And I added
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
to my build.gradle, following the instructions on LeakCanary website. After gradle build, I got
"/android-sdk/android-sdk_r22.6.2-linux/build-tools/21.1.1/aapt'' finished with non-zero exit value 1
This is part of my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'android'
apply plugin: 'maven'
android {
compileSdkVersion 19
buildToolsVersion '22.0.1'
defaultConfig {
multiDexEnabled true
}
lintOptions {
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
res.srcDirs = ['res']
}
instrumentTest.setRoot('tests')
}
dexOptions {
jumboMode = true
preDexLibraries = false
javaMaxHeapSize = '2g'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url "http://XXXXX/nexus/content/repositories/releases"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name: 'ShortcutBadger-1.0.1', ext: 'aar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
When I updated the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1, it worked.
Hope this can help anyone having this problem.
I changed
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
to
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
As well as the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1 as suggested by CherryWang https://stackoverflow.com/a/30496364/1247248
I got this from a comment in Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)
Related
For image processing i want to sync tessaract OCR in Android..i dont knw how to sync..!! when i tried to do some changes it shows "gradle sync failed"..
Here is setting.gradle and build.gradle
// setting.gradle:
include ':app'
include ':libraries:tess-two'
build.gradle of MyApplication:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.raghavan.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
build.gradle of tess-two:
// 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.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
}
This is my .gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.test.android.sk"
minSdkVersion 15
targetSdkVersion 23
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
}
dependencies {
compile 'com.google.android.gms:play-services:8.4.0'
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/android-support-v7-recyclerview-22.2.1.jar')
compile files('libs/applovin-6.1.5.jar')
compile files('libs/appodeal-1.14.6.jar')
compile files('libs/chartboost-6.2.0.jar')
compile files('libs/flurry-analytics-6.2.0.jar')
compile files('libs/unity-ads-1.4.7.jar')
compile files('libs/inmobi-5.2.0.jar')
compile files('libs/my-target-4.2.0.jar')
compile files('libs/yandex-metrica-2.30.jar')
}
When I build my Android app, I get the next error:
Error:Execution failed for task ':dexRelease'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
Install multidex but new error: Error:Execution failed for task ':packageAllReleaseClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: android/support/v4/view/PagerAdapter.class
Help! Its my .gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "test.app.android.player"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
}
dependencies {
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/android-support-v7-recyclerview-22.2.1.jar')
compile files('libs/applovin-6.1.5.jar')
compile files('libs/appodeal-1.14.6.jar')
compile files('libs/chartboost-6.2.0.jar')
compile files('libs/flurry-analytics-6.2.0.jar')
compile files('libs/inmobi-5.2.0.jar')
compile files('libs/my-target-4.2.0.jar')
compile files('libs/unity-ads-1.4.7.jar')
compile files('libs/yandex-metrica-2.30.jar')
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.android.support:multidex:1.0.0'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
And i got this error in logcat see this: Error:Execution failed for task ':packageAllReleaseClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/v4/view/PagerAdapter.class
I dont find duplicate
You have to remove
compile files('libs/android-support-v4-22.2.1.jar')
The 'com.google.android.gms:play-services-ads:8.4.0' has a dependency with com.android.support:support-v4:23.0.0. In this way you adding twice the same class with different version.
I have been getting Top level exception in android studio, i am using appcompat and sliding menu library. I know i am getting the exception because of conflict of Android Support Libraries as explained in some of the previous threads in stackoverflow. I have tried All the the methods shown in threads like including configuraion etc.
here is my Build.gradle(root)
// 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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.android.support', module: 'support-v4'
}
}
allprojects {
repositories {
jcenter()
}
}
Here is my Build.Gradle(App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
applicationId "com.danaraddi.cprograms"
minSdkVersion 8
targetSdkVersion 21
versionCode 9
versionName "7.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.2'
}
// animations
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.0.8#aar'
}
// inject views
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.jakewharton:butterknife:5.1.2'
}
dependencies {
// Your other dependencies go here
compile project(':library')
}
Here is my Build.Gradle(Lib - SlidingMenu)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
Here is my Log Cat
Error:Execution failed for task ':app:dexDebug'.
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
PS : I Have places configuration in root,app build.gradle too , it builds successfully after a clean project and then after the same error.
Add
dexOptions {
preDexLibraries = false
}
instead of
dexOptions {
incremental true
}
to build.gradle file inside the android block
On import ListViewAnimation library, I get rebuild error
Error:(7) A problem occurred evaluating project ':library'.
Could not find method instrumentTestCompile() for arguments [org.mockito:mockito-core:1.9.5, build_n73cqp2judtlhpna5h10rio8c$_run_closure1_closure3#20e75be5] on project ':library'.
This is the imported module build.gradle:
apply plugin: 'android-library'
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
instrumentTestCompile ('org.mockito:mockito-core:1.9.5') { exclude group: 'org.hamcrest' }
instrumentTestCompile ('com.google.dexmaker:dexmaker-mockito:1.0') { exclude group: 'org.hamcrest' }
instrumentTestCompile ('junit:junit:4.11') { exclude group: 'org.hamcrest' }
instrumentTestCompile 'org.hamcrest:hamcrest-all:1.3'
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
instrumentTest {
java.srcDirs = ['tests/java']
}
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionName project.VERSION_NAME
versionCode Integer.parseInt(new Date().format('yyyyMMddHH'))
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
apply from: '../maven_push.gradle'
What is the problem ?
instrumentTest has been renamed in androidTest in recent android-gradle-plugin
You have to rename in the build.gradle :
instrumentTestCompile --> androidTestCompile
instrumentTest --> androidTest