Gradle DSL method not found: compile() when switched computers - android

On my home desktop (Ubuntu) my project runs fine but when I open the project at work (ubuntu), the project fails to sync as the message says:
Gradle project sync failed. Basic functionality will not work properly.
Gradle DSL method not found: 'compile()'
Error:(11,0)
This is my module gradle
apply plugin: 'com.android.application'
apply plugin: 'com.parse'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.parse.com/repo' }
}
dependencies {
classpath 'com.parse.tools:gradle:1.+'
compile 'com.stripe:stripe-android:+'
}
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.2.0'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
/* Uncomment if you enable ProGuard and you want to automatically upload symbols on build.
parse {
applicationId YOUR_APPLICATION_ID
masterKey YOUR_MASTER_KEY
// Make symbol upload automatic. Otherwise, use e.g. ../gradlew parseUploadSymbolsDebug;
uploadSymbols true
}
*/
and this is the project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
}
}
ext {
compileSdkVersion = 22
buildToolsVersion = "22"
minSdkVersion = 9
targetSdkVersion = 22
}

Move compile 'com.stripe:stripe-android:+' from the dependencies closure in buildscript to your other dependencies closure. com.stripe:stripe-android is a library, not a Gradle plugin.

Related

google-services.json missing error

The file google-sevices.json is missing from module root folder even the file is in the app directory. My gradle version is 2.10. I have spent most of my time to solve this issue but still I cannot resolve the issue.
Project-level 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:2.1.0'
classpath 'com.google.gms:google-services:2.1.0' //this is the latest version
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
App-Level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myairticket.testpush3"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { res.srcDirs = \['src/main/res', 'src/main/jsonfiles'\] } }
}
dependencies {
compile fileTree(dir: 'libs', include: \['*.jar'\])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
apply plugin:'com.google.gms.google-services
I would double check that it's in your app folder and not in the /res folder. If you dragged the file in to Android Studio and you were in the Android view instead of Project Files, there's a good chance it got copied into the wrong directory.

Gradle DSL method not found: 'buildToolsVersion()'

I am new in Android-Studio
In that I have imported facebook and one other third party sdk
but I am getting following error
Error:(16, 0) Gradle DSL method not found: 'buildToolsVersion()'
Possible causes:The project 'EmojiShare' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file, The build file may be missing a Gradle plugin.
Apply Gradle plugin
my build.gradle file's code is below
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
in app/build.gradle the code is
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "emoji.drcsystems.com.emojishare"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':EmojiconApp')
}

Error:(20, 0) Gradle DSL method not found: 'compile()'

I have looked at other related but none seems to Solve my Problem in Gradle.
Here is my Build Gradle (Module App )
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.abdul_000.project"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v13.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
}
// 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
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
} apply plugin: 'application'
allprojects {
repositories {
jcenter()
}
}
}
The are it gives me
"Error:(20, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Project' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin"
What am I doing wrong ?
You cannot add compile dependencies to global build.gradle file. Removing the second dependencies block in your global build.gradle file would fix the error.

Build script error, unsupported Gradle DSL method found: 'useOldManifestMerger()'!

My build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
useOldManifestMerger false
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Without line useOldManifestMerger false it builds ok.
gradle version: 1.10.
gradle android plugin: don't know where to look.
I think it is trying to use pre 0.10 of gradle android plugin. How can I reinstall it?

multiproject gradle build error: package does not exist

I have some problems with building multiproject with gradle. I read all similar questions but nothing help. The structure of my projects looks like:
App/
settings.gradle
app/
build.gradle
libraries/
Core(git submodule)/
Core/
build.gradle
libraries/
ZBarLibrary/
build.gradle
settings.gradle
App/settings.gradle
include ':App', ':libraries:Core', ':libraries:ZBarLibrary'
project(':libraries:Core').projectDir = new File(settingsDir, 'libraries/Core/Core')
project(':libraries:ZBarLibrary').projectDir = new File(settingsDir, 'libraries/Core/libraries/ZBarLibrary')
App/app/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile project(':libraries:Core')
}
App/libraries/Core/Core/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
instrumentTestCompile "junit:junit:4.5+"
compile project(':libraries:ZBarLibrary')
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
App/libraries/Core/libraries/ZBarLibrary/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
Command "gradle build" in App directory generates error: "package com… does not exist". This package is used in app module but it is find in App/libraries/Core/Core/src/main/java. Could you help me?
Your app module's build.gradle should contain (among other things)
apply plugin: 'com.android.application'
dependencies {
compile project(':my_library_module')
}
Your library module's build.gradle file should contain
apply plugin: 'com.android.library'
If you're using Core as library you should change apply plugin: 'android' to apply plugin: 'android-library' in App/libraries/Core/Core/build.gradle
To resolve the package not found errors, in the app module's build.gradle file I added
dependencies {
// ...
compile project(':library')
}
which adds the library module as a dependency to the app module
I have the same problem with Gradle 6.4 (multi-module project) and Java 13
Project structure:
app:
backend:
/src
build.gradle
base:
/src
build.gradle
build.gradle
settings.gradle
Main class is contained in base/build.gradle and also base-module depends on backend-module.
SOLUTION: It is necessary to add following rows to backend/build.gradle
jar {
enabled = true
}
bootJar {
enabled = false
}
and check that base/build.gradle has the following rows:
bootJar {
archivesBaseName = 'base'
}
dependencies {
implementation project(":backend")
}
Just in case, for newcomers in gradle put the listing of settings.gradle file:
rootProject.name = 'app'
include 'backend', 'base'

Categories

Resources