web-dev-qa-db-ja.com

「:app」は現在のコンテキストでは実行できません-Android studio 3.2.1

私は次のように私のプロジェクトでOneSignalから使用しています:

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'
}

そして、ここにあります:

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
}

しかし、私は以下のエラーを取得します:

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

私のエラーは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' }
}

しかし、どうすればこの問題を解決できるかわかりません!

classpath 'com.Android.tools.build:gradle:3.3.0-alpha12'のバージョンを操作しましたが、動作しません!

そして、私はこれを読みます ページ しかし、私は私の問題を解決することはできません!

My Androidスタジオバージョンは3.2.1です。

OneSignalの依存関係をページのトップに挿入しましたが、まだ機能しません!

8
jo jo

行う必要があるのは、変更です

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

に:

dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.0'
}
16
Joel Casasayas

そのGradleスクリプトにはかなりの数の構文エラーがあります:

コピーして貼り付けたものを置き換えます どちらかと "または'

buildscriptを2回追加することも意味がありません。

0
Martin Zeitler