Could not find method classpath() error - java

when I try to compile my project in Android Studio 3:
Could not find method classpath() for arguments [com.android.tools.build:gradle:3.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
this is my build.gradle (Module:app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "ir.chistaapplication.www.myapplication20"
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 {
classpath 'com.android.tools.build:gradle:3.0.1'
}

Don't put classpath dependencies inside app/build.gradle. Put them inside the buildScript dependencies in your project build.gradle
buildScript {
dependencies {
// here
}
}

Related

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateReleaseBuildConfig

Here is my build.gradel modul.app
PROBLEM org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateReleaseBuildConfig
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.packagename"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
// Prevent OutOfMemory with MultiDex during the build phase
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
implementation 'com.google.android.gms:play-services:+'exclude module: 'support-v4'
implementation 'com.parse:parse-android:1.10.3'
implementation 'com.android.support:multidex:1.0.1'exclude module: 'support-v4'
implementation 'com.google.android.ads.consent:consent-library:1.0.3'
}
I get tired with this problem when i want to build this project to apk from buildbox by android studio

Could not get unknown property 'resolutionStrategy' for project ':app' of type org.gradle.api.Project

I was getting this error:
Error:Execution failed for task ':app:preDebugBuild'.
Android dependency 'com.android.support:appcompat-v7' has different version for the compile (25.3.1) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution
A quick search on google showed me that I should include in my app/build.gradle:
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "25.3.1"
}
}
Now I get a new error:
Could not get unknown property 'resolutionStrategy' for project ':app' of type org.gradle.api.Project.
here is my full app/build.gradle code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
dexOptions {
preDexLibraries = false
}
defaultConfig {
applicationId "co.test.Test"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
flatDir {
dirs 'libs'
maven { url "http://dl.bintray.com/chat-sdk/chat-sdk-android" }
google()
maven { url "https://jitpack.io" }
mavenLocal()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
implementation 'co.chatsdk.chatsdk:chat-sdk-core:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-ui:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-adapter:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-file-storage:4.0.8'
}
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "25.3.1"
}
}
apply plugin: 'com.google.gms.google-services'
my library/build.gradle:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
}
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:27.1.0'
implementation files('libs/aacdecoder-android-0.8.jar')
}

Error while build apk

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\Akash\Desktop\android\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Akash.gradle\caches\transforms-1\files-1.1\support-compat-25.2.0.aar\876e5d10a24579a64796f25edbd33794\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewCompat.class]))
App Gradle :
apply plugin: 'com.android.application'
android {`enter code here`
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.razorworld.bike"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1')
}

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

I am new to Android and Android Studio so, I downloaded a project that I also need for my class then I got this error. I could not find my answer here, although there was a question like mine. Please help me to run this program that I downloaded from internet and solve this error, thank you.
These are my gradles:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.gettaxi"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
And:
// 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.2'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
}

Can't compile app Error code 1

I'm trying to use the aacdecoder library to listen an online radio in my app, the thing is that it doesn't compile, I have added the jar library and added to the build.gradle, this is my code
MultiPlayer aacMp3Player = new MultiPlayer();
aacMp3Player.playAsync( "http://cast.direcnode.com:11413/stream" );
And this is the error:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/Ger/Documents/sdk/build-tools/android-4.4W/dx --dex --num-threads=4 --output /Users/Ger/Desktop/Radio/app/build/intermediates/dex/debug /Users/Ger/Desktop/Radio/app/build/intermediates/classes/debug /Users/Ger/Desktop/Radio/app/build/intermediates/dependency-cache/debug /Users/Ger/Desktop/Radio/app/build/intermediates/pre-dexed/debug/aacdecoder-android-0.8-470e8c408147266db0ce9215156fc542209cf849.jar
Error Code:
1
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "ger.radio"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('lib/aacdecoder-android-0.8.jar')
compile fileTree(dir: 'lib', include: ['*.jar'])
}
task copyNativeLibs(type: Copy) {
from(new File('libs')) { include '**' }
into new File(buildDir, 'native-libs')
}

Categories

Resources