【问题标题】:While I'm trying to generate android build I'm getting Could not determine the dependencies of task ':compileDebugJavaWithJavac' error当我尝试生成 android 构建时,我得到了无法确定任务“:compileDebugJavaWithJavac”错误的依赖关系
【发布时间】:2019-09-19 06:07:02
【问题描述】:

我在这里使用的是 android gradle 3.4.1,这是分发 url。

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

这是我的 build.gradle 文件部分。请提出一些解决方案,因为我试图从过去这么多天找出这个错误。

 apply plugin: 'com.android.application'

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }
}

// Allow plugins to declare Maven dependencies via build-extras.gradle.

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }

    }
}

这是我的 cordovaLib build.gradle 文件

   ext {
    apply from: 'cordova.gradle'
    cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

   dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = 'org.apache.cordova'
version = '6.3.0'

android {
    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion
    publishNonDefault true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        minSdkVersion 14
    }
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'Cordova'
                url 'https://cordova.apache.org'
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'stevengill'
                        name 'Steve Gill'
                    }
                }
                scm {
                    connection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    developerConnection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    url 'https://git-wip-us.apache.org/repos/asf?p=cordova-android'

                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

artifacts {
    archives sourcesJar
}

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'cordova-android'
        userOrg = 'cordova'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
        websiteUrl = 'https://cordova.apache.org'
        issueTrackerUrl = 'https://issues.apache.org/jira/browse/CB'
        publicDownloadNumbers = true
        licenses = ['Apache-2.0']
        labels = ['android', 'cordova', 'phonegap']
        version {
            name = '6.3.0'
            released  = new Date()
            vcsTag = '6.3.0'
        }
    }
}

我已经在 Ionic 3 中构建了这个项目。在我使用 gradle 版本 2.3 之前,但现在要构建 android build 我将它更新到 5.6.2

【问题讨论】:

    标签: android gradle ionic3


    【解决方案1】:

    请在 app.gradle 中添加构建类型设置。添加发布 {} 和调试 {} 设置

    构建类型 {

        release {
    
            lintOptions {
                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
            }
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.Production
            buildConfigField "String", "SERVER_URL", '"http://192.131.543"'    
          }
    
    
        debug {
            debuggable true
            buildConfigField "String", "SERVER_URL", '"http://192.131.543"'
    
        }
    }
    

    【讨论】:

    • 您的建议解决了这个问题,但现在我又遇到了另一个错误。出了什么问题:无法确定任务':compileReleaseJavaWithJavac'的依赖关系。 > 无法解析配置“:releaseCompileClasspath”的所有任务依赖关系。 > 无法解析项目:CordovaLib。要求:项目:>项目:声明从配置'releaseCompile'到配置'release'的依赖关系,该依赖关系未在项目描述符中声明:CordovaLib
    • 您是否添加了发布设置。请再次交叉检查。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 2021-11-02
    • 2020-04-15
    • 2021-06-18
    • 2021-11-20
    相关资源
    最近更新 更多