Error:(8, 0) Gradle DSL method not found: compile() - Android Studio

I'm trying to reduce google play services' impact on APK size. I get the following error when i try to synchronize the gradle proyect. I would be very thankful if somebody can help me with this problem.
Error8, 0) Gradle DSL method not found: 'compile()'
Possible causes:
- The project 'MorphingTunnelFreeLauncher' may be using a version of Gradle that does not contain the method. Gradle settings
- The build file may be missing a Gradle plugin.
The changes in the gradle code looks like this:
- build.gradle in googleplayservices_lib
apply plugin: 'com.android.library'
android {
compileSdkVersion 9
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled true //changed
shrinkResources true //changed
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/google-play-services.jar')
}
- build.gradle in the app itself:
// 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.1.0'
compile 'com.google.android.gmslay-services-ads:6.5.+'//changed
}
}
allprojects {
repositories {
jcenter()
}
}

Related

Error:duplicate files during packaging of APK

I clean and rebuild my project with success but when i run it, it gives me an error. I tried many solution but i couldn't solve with them.
This is my error :
Code:
Error:duplicate files during packaging of APK /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/outputs/apk/projectAndroid-debug-unaligned.apk
Path in archive: AndroidManifest.xml
Origin 1: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/resources/resources-debug.ap_
Origin 2: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/javaResources/debug/AndroidManifest.xml
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'AndroidManifest.xml'
}
}
Error:Execution failed for task ':projectAndroid:packageDebug'.
Duplicate files copied in APK AndroidManifest.xml
File 1: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/resources/resources-debug.ap_
File 2: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/javaResources/debug/AndroidManifest.xml
This is my build gradle:
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '23.0.0 rc2'
defaultConfig {
applicationId "com.project.android"
minSdkVersion 14
targetSdkVersion 19
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
packagingOptions {
exclude 'AndroidManifest.xml'
}
}
}
dependencies {
compile project(':slidingMenuLibrary')
compile project(':pullToRefreshLibrary')
compile project(':placeActivity')
compile project(':jMC')
compile project(':salesforceSDK')
compile project(':library')
compile files('../libMaster/android-integration-2.3-SNAPSHOT.jar')
compile files('../libMaster/com.radaee.pdfex_view.jar')
compile files('../libMaster/core-2.3-SNAPSHOT.jar')
compile files('../libMaster/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
compile files('../libMaster/libGoogleAnalyticsServices-v3.01.jar')
compile files('../libMaster/urbanairship-lib-3.0.0.jar')
compile 'com.google.api.client:google-api-client-repackaged-com-google-common-base:1.2.3-alpha'
compile 'com.google.code.gson:gson:2.3.1'
compile ('com.android.support:support-v4:22.2.0'){
exclude group: 'multidex'
}
compile files('../libMaster/commons-lang3-3.1.jar')
compile files('../libMaster/aws-android-sdk-1.4.4-s3.jar')
compile files('../libMaster/aws-android-sdk-1.4.4-core.jar')
compile files('../libMaster/universal-image-loader-1.8.5-with-sources.jar')
}
I also tried this solution, but didn't work :
Code:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

android studio problem

Hi, i have the next problem, when i open a project in android stuidio, appear the next message
Error:Could not create an instance of Tooling API implementation using the specified Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.8'.
what could be? and What i can do?
Thanks for all
Have you tried updating Android Studio?
Also you could show build.gradle file for this project.
klisiecki said:
Have you tried updating Android Studio?
Also you could show build.gradle file for this project.
Click to expand...
Click to collapse
this show the file 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.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
}
Hi!
Try to use last version of android studio gradle plugin.
Just change line
Code:
classpath 'com.android.tools.build:gradle:1.5.0'
to
Code:
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'

Getting java.util.zip.ZipException: duplicate entry for SimpleJavaMail

While building apk for my project, I'm getting the following error:
Code:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/simplejavamail/email/AttachmentResource.class
Here's my gradle file:
Code:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.parassidhu.cdlumaths"
minSdkVersion 16
targetSdkVersion 24
versionCode 2
versionName "1.1"
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "8g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.github.paolorotolo:appintro:3.4.0'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.hotchemi:android-rate:1.0.1'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'org.simplejavamail:simple-java-mail:4.1.1'
compile files('libs/simple-java-mail-4.1.1.jar')
}
apply plugin: 'com.google.gms.google-services'
I
I have no idea what's wrong. I can test the app fine but when I Rebuild project/build apk/generate signed apk, I get this error. Sometimes the duplicate entry points to different class than AttachmentResource.class.

Unable to resolve all dependencies in android studio 3.0

I am getting these errors while syncing gradle:-
Error:Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Error:Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve com.android.support:design:26.1.0.
Error:Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1.
Error:Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve junit:junit:4.12.
Error:Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.
METHODS TRIED
i have tried adding GOOGLE MAVEN REPO, mavencentral all with url & without url.
i have tried deleting .gradle folder from C:\Users\<username>/.gradle.
i have tried gradle offline work and online work, both end up with same error message.
tried clean project & rebuilding.
tried INVALIDATE CACHE & RESTART.
tried degrading the android studio version.
I AM USING WINDOWS 64BIT WITH 4GB OF RAM AND DUAL CORE 2.0 GHZ PROCESSOR, AND ANDROID VERSION 3.0, GRADLE VERSION 4.1 & 4.3(LATEST), I HAVE INSATLLED ALL THE NECESSARY TOOLS & EVERYTHING UPDATED IN SDK MANAGER. ANDROID SUPPORT REPOSITORY & GOOGLE OFFLINE REPOSITORY BOTH INSTALLED.
WHENEVER I TRY TO SYNC IT WITH OFFLINE WORK IT END UP WITH ERROR (NO CACHED VERSION OF THIS (DEPENDENCY IS FOUND), AND WHENEVER I TRY TO SYNC WITH ONLINE WORK, THE ERRORS ARE SAME LISTED ABOVE IN BOTH CASES.
I HAVE TRIED EVERYTHING FROM STACK OVER FLOW & YOUTUBE.
BUILD.GRADLE PROJECT:MY APPLICATION.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
BUILD.GRADLE MODULE:APP
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.vipinsaini.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
CAN ANYONE PLZ HELP ME SOLVE THIS ISSUE. I am new to android studio plz omit mistakes.
Add google() to allprojects node in your root build.gradle file
allprojects {
repositories {
jcenter()
google()
}
}
Hey,
I have a same problem. I tried to do your solution, but already exist this code in build.gradle file.
I will be happy to another solution.
Thanks.
Try to Invalidate Cache/Restart that got the problem fixed for me
Unable to Resolve Dependencies
After much research and headache... Go to File\Settings\Gradle. Deselect the "Offline work" box. Now you can connect and download any necessary or missing dependencies.
Worked, thank you.
i tried invalidate and restart then delete .gradle file then uncheck the offline work but no use not clear the appcompact error

AAPT2 process unexpectedly exit. Error output"

Hi everyone
I was trying to build my app on android studio but suddunly ive got this erreo: AAPT2 process unexpectedly exit. Error output"
and after that i cant build my app.so i search about it and did every soultion on Internet but non of them work for me.
im trying to fix this issue for 2 days.so please help me to fix it
thanks.
THIS IS MY GRADLE FILE:
Code:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.weather5"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
delete you gradle file in studio dir then restart you studio

Categories

Resources