Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

':app' cannot be executed in the current context - android studio 3.2.1

I am using from OneSignal in my project like bellow:

def taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
def isPlay = !(taskRequests.contains("Foss") || taskRequests.contains("foss"))
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
    maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
if (isPlay) {
    apply plugin: 'io.fabric'
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "com.github.ben-manes.versions"

android {
    compileSdkVersion versions.compileSdk
    buildToolsVersion versions.buildTools

    defaultConfig {
        manifestPlaceholders = [onesignal_app_id               : “111”,
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: “111”]
        applicationId “zzz.zzz.android"
        minSdkVersion versions.minSdk
        targetSdkVersion versions.targetSdk
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

        def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
        def buildTime = new GregorianCalendar().format("MM-dd-yyyy' 'h:mm:ss a z")
        buildConfigField "String", "GIT_SHA", "\"${gitSha}\""

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    signingConfigs {
        release {
            storeFile project.rootProject.file(‘aaa.jks').getCanonicalFile()
            storePassword System.getenv("KEYSTORE_PASSWORD")
            keyAlias System.getenv("KEY_ALIAS")
            keyPassword System.getenv("KEY_PASSWORD")
        }

        debug {
            storeFile project.rootProject.file('debug.keystore').getCanonicalFile()
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }

    buildTypes {
        release {
            lintOptions {
                disable 'MissingTranslation'
                checkReleaseBuilds false
                // Or, if you prefer, you can continue to check for errors in release builds,
                // but continue the build even when errors are found:
                abortOnError false
            }
            buildConfigField "String", "REQUIRED_SERVER_VERSION", '"0.62.0"'
            buildConfigField "String", "RECOMMENDED_SERVER_VERSION", '"0.64.2"'
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            buildConfigField "String", "REQUIRED_SERVER_VERSION", '"0.62.0"'
            buildConfigField "String", "RECOMMENDED_SERVER_VERSION", '"0.64.2"'
            signingConfig signingConfigs.debug
            applicationIdSuffix ".dev"
        }
    }

    flavorDimensions "type"

    productFlavors {
        // includes proprietary libs
        play {
            dimension "type"
        }

        // only foss
        foss {
            dimension "type"
        }
    }

    packagingOptions {
        exclude 'META-INF/core.kotlin_module'
        exclude 'META-INF/main.kotlin_module'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    implementation 'com.netflix.rxjava:rxjava-android:0.20.3'
    implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    implementation 'com.joanzapata.iconify:android-iconify-material:2.2.2'
    implementation 'com.joanzapata.iconify:android-iconify-material-community:2.2.2'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    implementation 'com.onesignal:OneSignal:3.+@aar'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    implementation 'org.jsoup:jsoup:1.10.1'
    implementation 'com.mindorks.android:prdownloader:0.4.0'
    implementation 'org.pcap4j:pcap4j-core:1.7.3'
    implementation 'org.pcap4j:pcap4j-packetfactory-static:1.7.3'
    implementation 'org.minidns:minidns-client:0.3.0'
    implementation project(':player')
    implementation project(':emoji')
    implementation project(':draw')
    implementation project(':util')
    implementation project(':core')
    implementation project(':suggestions')

    implementation libraries.kotlin
    implementation libraries.coroutines
    implementation libraries.coroutinesAndroid

    implementation libraries.appCompat
    implementation libraries.recyclerview
    implementation libraries.constraintlayout
    implementation libraries.cardview
    implementation libraries.browser

    implementation libraries.androidKtx
    implementation libraries.fragmentsKtx

    implementation libraries.dagger
    implementation libraries.daggerSupport
    kapt libraries.daggerProcessor
    kapt libraries.daggerAndroidApt

    implementation libraries.flexbox
    implementation libraries.material

    implementation libraries.room
    kapt libraries.roomProcessor
    implementation libraries.lifecycleExtensions
    kapt libraries.lifecycleCompiler
    implementation libraries.viewmodelKtx
    implementation libraries.workmanager

    implementation libraries.rxKotlin
    implementation libraries.rxAndroid

    implementation libraries.moshi
    implementation libraries.okhttp
    implementation libraries.okhttpLogger

    implementation libraries.timber
    implementation libraries.threeTenABP

    implementation libraries.fresco
    api libraries.frescoOkHttp
    implementation libraries.frescoAnimatedGif
    implementation libraries.frescoWebP
    implementation libraries.frescoAnimatedWebP

    implementation libraries.glide

    kapt libraries.kotshiCompiler
    implementation libraries.kotshiApi

    implementation libraries.frescoImageViewer

    implementation libraries.markwon

    implementation libraries.aVLoadingIndicatorView

    implementation libraries.livedataKtx

    implementation 'com.google.code.findbugs:jsr305:3.0.2'

    // Proprietary libraries
    playImplementation libraries.fcm
    playImplementation libraries.firebaseAnalytics
    playImplementation libraries.playServicesAuth
    playImplementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') { transitive = true }
    playImplementation('com.crashlytics.sdk.android:answers:1.4.3@aar') { transitive = true }

    testImplementation libraries.junit
    testImplementation libraries.truth
    androidTestImplementation libraries.espressoCore
    androidTestImplementation libraries.espressoIntents
}

kotlin {
    experimental {
        coroutines "enable"
    }
}

androidExtensions {
    experimental = true
}
preBuild.dependsOn compileSdk
if (isPlay) {
    apply plugin: 'com.google.gms.google-services'
}

And here is:

buildscript {
    apply from: rootProject.file('dependencies.gradle')
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha12'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
        classpath 'com.google.gms:google-services:4.0.2'
        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://jitpack.io" }
    }

    apply from: rootProject.file('dependencies.gradle')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

But get me bellow error:

Project#afterEvaluate(Closure) on project ':app' cannot be executed in the current context.

I know my error is for OneSignal:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
    maven { url 'https://maven.google.com' }
}

But I don't know how can I resolve this problem!

Manipulated the version of classpath 'com.android.tools.build:gradle:3.3.0-alpha12' but don't work!

And I read this page but I can't resolve my problem!

My android studio version is 3.2.1.

I inserted the dependencies of OneSignal to top of page but don't work yet!

like image 917
jo jo Avatar asked Oct 24 '18 08:10

jo jo


1 Answers

Only need to do, is change

dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.3'
}

to:

dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.0'
}
like image 147
Joel Casasayas Avatar answered Nov 15 '22 21:11

Joel Casasayas