ERROR: Could not find method android() for arguments - java

I am facing a problem, when i sync my project this gradle error occurs :(
ERROR: Could not find method android() for arguments [build_4igxve2xutpcfkae0ab7hnkia$_run_closure1#353dd2ed] on project ':app' of type org.gradle.api.Project.
Open File
This is my Build.gradle(project: name)
// 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-beta6'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:4.3.2'
// 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
}
This is my build.gradle(Module:App)
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.instagram"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
//androidTestImplementation 'com.android.support.test:runner28.0.0'
}
apply plugin: 'com.google.gms.google-services'

You appear to be missing this line from the top of your module's build.gradle file:
apply plugin: 'com.android.application'

Related

Could not resolve all files for configuration ':app:debugRuntimeClasspath

I am getting some error
Execution failed for task ':app:desugarDebugFileDependencies'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.google.guava:listenablefuture:1.0.
And Show Something like that as well
Required by:
project :app > androidx.appcompat:appcompat:1.4.0 > androidx.core:core:1.7.0
> androidx.concurrent:concurrent-futures:1.0.0
How can I solve that issue. Please Some one Help Me
Here is My Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.example.bloodbuddy"
minSdkVersion 21
targetSdkVersion 31
versionCode 6
versionName "2.0.1"
testInstrumentationRunner "androidx.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation("androidx.constraintlayout:constraintlayout:2.1.2")
implementation 'com.google.firebase:firebase-database:20.0.3'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'com.google.firebase:firebase-storage:20.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Have you found the answer? Because you didn't show your project root build.gradle and maybe the build.gradle in your project root directory didn't have the mavenCentral() repository.
Just go to your build.gradle repository and add the mavenCentral().
Project root directory build.gradle
buildscript {
repositories {
google()
mavenCentral() // <= add this
}
dependencies {
// make sure to have this classpath
classpath 'com.google.gms:google-services:4.3.10'
}
}
........
allprojects {
repositories {
google()
mavenCentral() // <= add this
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

How to fix "Cause: invalid type code: 8F"

Cause: invalid type code: 8F this error raise when try to take apk build.
Already I tried.. -- clean and rebuild -- Invalidate and restart -- jdk path setting -- experimental option
Android studio version 3.3.1
gradle version -- classpath 'com.android.tools.build:gradle:3.2.1'
project level gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'nl.psdcompany:duo-navigation-drawer:2.0.6'
apply plugin: 'com.google.gms.google-services'
}
I attached my app and project level gradle file.

Problem with dependencies gradle exception

What the hell is this? I know that I have to upgrade something within my app dependencies but it does not point out what and where!!
org.gradle.api.GradleException: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.5,16.0.5], [16.0.4,16.0.4], [16.3.0,16.3.0]], but resolves to 16.3.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
I added the following dependencies for admob ads and gave me that error :
implementation 'com.google.android.gms:play-services-ads:17.1.1'
Project level gradle :
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
// 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
}
app level :
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.genesisbc.marketplace"
minSdkVersion 23
targetSdkVersion 28
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:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.firebaseui:firebase-ui-storage:4.1.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:28.0.0'
}
apply plugin: 'com.google.gms.google-services'

Program type already present: android.support.v4.R

I am trying to generate a signed apk and I am getting the error:
Program type already present: android.support.v4.R
I have tried excluding support-v4 from some dependencies. But that didn't help. I have searched for answers but none couldn't solve mine.
But the app runs in debug mode fine.
Thank you very much for your time and assistance in this matter.
Here's my gradle app file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.android.puchotask1"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'com.facebook.android:facebook-android-sdk:4.33.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'ai.api:sdk:2.0.7'
implementation 'ai.api:libai:1.6.12'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.dnkilic.waveform:waveform:0.9.3'
}
apply plugin: 'com.google.gms.google-services'
gradle project file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.1'
// 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
}
You need to exclude the support appcompat-v7 from this dependency:
implementation 'com.dnkilic.waveform:waveform:0.9.3'
with this:
implementation ('com.dnkilic.waveform:waveform:0.9.3') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}

Could not find android-maven-gradle-plugin.jar in Android Studio 3.1?

My Android is work fine in Android Studio 3.0.1 , but it show the follow build error after I update to the Android Studio 3.1.
Could not find android-maven-gradle-plugin.jar (com.github.dcendents:android-maven-gradle-plugin:2.0).
Searched in the following locations:
https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/2.0/android-maven-gradle-plugin-2.0.jar
The build.gradle is like the following:
// 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.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And in app/build.gradle :
apply plugin: 'com.android.application'
apply plugin: 'android-maven'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.aitrix.wen.seaglider"
minSdkVersion 21
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'
compile project(':AHRSView')
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Did I missing something ? Thanks in advance.
After I update the following , the project work fine.
Update
classpath 'com.android.tools.build:gradle:3.0.1'
to
classpath 'com.android.tools.build:gradle:3.1.0'
And Update
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
to
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
also update the gradle-wrapper.properties to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Categories

Resources