Running gradle build is failed When try to run on device? - android

before that i have uninstalled visual studio code , android studio and gradle , my project was running on device fine , but when reinstalled tools and try command :
ionic cap run android --livereload --consolelogs --serverlogs --external
to build and run my project on my device , I m facing this error :
Build file 'E:\Mes Projets\Mobile\iStore\iStore\node_modules\#capacitor-community\fcm\android\build.gradle' line: 29
[capacitor]
[capacitor] * What went wrong:
[capacitor] A problem occurred evaluating project ':capacitor-community-fcm'.
[capacitor] > initialize must be called for meta class of class build_asct3wckhlowifz9k3uacapmo$_run_closure2$_closure6(class org.codehaus.groovy.runtime.metaclass.ClosureMetaClass) to complete initialisation process before any invocation or field/property access can be done
my build.gradle file :
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '21.0.1'
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Note : im using Fcm for firebase messaging
how can i solve this error , any help ?
thanks

Related

Failed to resolve one of the libraries in Android Studio gradle dependencies

I want to include a library in Android Studio , but it displays error like below :
Failed to resolve: com.andrognito.pinlockview:pinlockview:2.1.0
Failed to resolve: com.andrognito.patternlockview:patternlockview:1.0.0
How to fix this problem?
-build.gradle (App)
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.multiverse.appprotector"
minSdk 23
targetSdk 32
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 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
}
Other dependencies, which I consider are not relevant to the error:
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'junit:junit:4.13.2'
implementation 'androidx.test.ext:junit:1.1.3'
implementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.biometric:biometric:1.1.0'
Please go through link
If possible try latest library for the same because both libraries are not maintained from last few years.
Add jCenter repository in project’s build.gradle file as shown below and sync your project:
allprojects {
repositories {
jcenter()
. . .
}
}
Note- In the latest android code it will available in settings.gradle file
pluginManagement {
repositories {
jcenter()
...
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
jcenter()
..
}
}

Failed to apply plugin [id 'com.chaquo.python'] while gradle build

I am trying to use python in my android app by using chaquopy. I found tutorial for integrating chaquopy in android here .
I update my gradle file for app and project level A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.chaquo.python']
No such property: dslScope for class: com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet.
Here is my code for build.gradle app level
apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
sourceSets {
python {
srcDirs = ["src/main/python"]
}
}
python {
buildPython "usr/bin/python3"
buildPython "python3"
}
ndk {
abiFilters "armeabi-v7a", "x86"
}
applicationId "com.softvision.nowyouseeus"
minSdkVersion 19
targetSdkVersion 29
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.google.mlkit:face-detection:16.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
bild.gradle project level
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {url "https://chaquo.com/maven"}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath 'com.chaquo.python:gradle:6.3.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
}
Chaquopy 6.3.0 isn't compatible with Android Gradle plugin version 4.1.0, and you should have received a warning about that.
See here for the compatible combinations. You should probably just upgrade to the current Chaquopy version, 9.0.0.

Failed to resolve: appcompat-v7 android studio 3.2.1

I exported my Build box project and opened it on Android studio. But Unable to Build it.I'm getting this error.
Failed to resolve: appcompat-v7
Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.test.test1"
minSdkVersion 16
targetSdkVersion 26
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
implementation 'com.google.android.gms:play-services:+'
implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
// More deps here //
}
anyone know how to fix this ?
Add this in dependencies:
implementation 'com.android.support:appcompat-v7:27.1.1'
Add this in project gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

Error : cause android.compileSdkVersion is missing

I am recently started to work on the Android Studio. When I am doing sync with gradle then it is giving me a error .
Error : Cause: android.compileSdkVersion is missing!
Guys what could be reason for this, I already have same compileSDKVersion and build tool installed. I see many threads that saying to confirm that you have same sdk version installed in your system but in my case it is already installed.
build.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
I met this problem too, but I don't know whether my solution suit for you.
I just change the position of this script: apply from: 'maven_push.gradle' to the bottom in build.gradle file, and BUILD SUCCESSFUL!
I post my answer here, you can try it.: Building Android Studio project on Jenkins? android.compileSdkVersion is missing
I did this. It works on Android Studio 0.4.6:
/android_common.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:+'
}
allprojects {
apply plugin: 'idea'
repositories {
mavenCentral()
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
}
def langLevel = 1.7
idea {
project {
jdkName = langLevel
languageLevel = langLevel
}
}
/app/build.gradle
apply plugin: 'android'
apply from: "${rootDir}/android_common.gradle"
android {
defaultConfig {
versionCode 1
versionName "1.0"
packageName "your.app.package.name"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.j256.ormlite:ormlite-android:4.+'
compile 'joda-time:joda-time:2.+'
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
apply plugin: 'android-unit-test'
dependencies {
instrumentTestCompile 'junit:junit:4.+'
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
testCompile 'junit:junit:4.+'
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
}
If something is missing, and you have clearly declared it, it means that it was queried before it was defined. Move the query (code that requires that variable) somewhere lower, or to a later position in the sequence and it will be fixed.
try this :
apply plugin: 'android'
apply from: "${rootDir}/android_common.gradle"
move your apply from: "${rootDir}/android_common.gradle"
to last lines

Error : Gradle 'HelloWorld' project refresh failed: Build script error, unsupported Gradle DSL method found: 'setRoot()'!

Hi I am doing testing of my android app using gradle in the AndroidStudio. I am using this framework RoboLectric for doing it all.
It is giving me an error when I sync it with gradle files. Guys, share your views for this problem.
Gradle settings
3:35:14 PM Gradle 'HelloWorld' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'setRoot()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Gradle settings
In the folder app, there is build.gradle, this is which I have right now
apply plugin: 'android'
apply plugin: 'android-test'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
testCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'junit:junit:4.10'
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
}
In the HelloWorld, there is another build.gradle where I have
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
}
}
allprojects {
repositories {
mavenCentral()
}
}
As Peter suggested in the comment to declare the sourceSets inside the android { .... }.
It worked for me.
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}

Categories

Resources