首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我实现了VirtualAPK库,但无法执行任务':app:compileDebugJavaWithJavac‘

我实现了VirtualAPK库,但无法执行任务':app:compileDebugJavaWithJavac‘
EN

Stack Overflow用户
提问于 2019-05-17 18:38:17
回答 1查看 432关注 0票数 0

我实现了VirtualAPK库,但无法构建项目

我的Project gradle文件:

代码语言:javascript
复制
buildscript {
    repositories {
        google()
        jcenter()

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

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

我还实现了库,并按照Module gradle中的库指南进行了应用

代码语言:javascript
复制
apply plugin: 'com.android.application'

apply plugin: 'com.didi.virtualapk.host'

android {
    compileSdkVersion 28
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.example.vspace"
        minSdkVersion 19
        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:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.didi.virtualapk:core:0.9.8'

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

在那之后,我尝试构建项目,并得到类似于()的错误:

代码语言:javascript
复制
Compiling with JDK Java compiler API.
Created classpath snapshot for incremental compilation in 0.024 secs.
[INFO][VAHostPlugin] Used compileClasspath: debug

> Task :app:compileDebugJavaWithJavac FAILED

:app:compileDebugJavaWithJavac (ThreadDaemon worker,5,main)完成。花了2.586秒。

代码语言:javascript
复制
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodException: No similar method computeBuildMapping with params [class org.gradle.invocation.DefaultGradle_Decorated] could be found on type class com.android.build.gradle.internal.ide.ModelBuilder.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

我还试图降级和升级gradle version,也尝试了旧的Android Studio3.0.1和3.4.1。但这里什么都不起作用。所以,如果有人能帮上忙,那肯定是可以接受的。

我也推荐了This question,但它帮不了我。

EN

回答 1

Stack Overflow用户

发布于 2019-05-18 21:14:26

VirtualApk正在执行gradle 3.4.1中不支持this.and computeBuildMapping (基于您的帖子中的错误)。

代码语言:javascript
复制
if (project.extensions.extraProperties.get(Constants.GRADLE_3_1_0)) {
                    ImmutableMap<String, String> buildMapping = Reflect.on('com.android.build.gradle.internal.ide.ModelBuilder')
                            .call('computeBuildMapping', project.gradle)
                            .get()
                    compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
                            applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null, buildMapping)
                } else {
                    compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
                            applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null)
                }

因此,尝试使用gradle插件3.1.0和gradle版本4.4构建您的项目

代码语言:javascript
复制
dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

gradle-wrapper.properties

代码语言:javascript
复制
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56184722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档