project的build.gradle添加依赖后build报错

project的build.gradle添加依赖后build报错

# 具体遇到的问题

# 报错信息的截图

app的gradle代码添加依赖后build报错如下:

10:40:29: Executing task 'dependencies'...

Executing tasks: [dependencies] in project E:\Kotlin\HotFix


> Configure project :app
TinkerSupport Plugin Version: 1.1.4
    Requires:
        Android Plugin for Gradle, Revision 2.0.0 or higher
    Dependencies:
        Gradle 2.10 or higher (Current Gradle Version: 6.1.1)

apply plugin: 'com.tencent.tinker.patch'
----------------------tinker build warning ------------------------------------
tinker auto operation:
excluding annotation processor and source template from app packaging. Enable dx jumboMode to reduce package size.
enable dx jumboMode to reduce package size.
disable preDexLibraries to prevent ClassDefNotFoundException when your app is booting.
disable archive dex mode so far for keeping dex apply.

tinker will change your build configs:
we will add TINKER_ID=null in your build output manifest file build/intermediates/manifests/full/*

if minifyEnabled is true
you will find the gen proguard rule file at build/intermediates/tinker_intermediates/tinker_proguard.pro
and we will help you to put it in the proguardFiles.

if multiDexEnabled is true
you will find the gen multiDexKeepProguard file at build/intermediates/tinker_intermediates/tinker_multidexkeep.pro
and we will help you to put it in the MultiDexKeepProguardFile.

if applyResourceMapping file is exist
we will build app apk with resource R.txt file
if resources.arsc has changed, you should use applyResource mode to build the new apk!
-----------------------------------------------------------------
----------------------tinker-support build warning ------------------------------------
if you not set autoBackupApkDir we will auto backup the build file to E:\Kotlin\HotFix\app/tinker.

if overrideTinkerPatchConfiguration is true
we will override tinker patch configuration��you must use tinker-support's configuration

you will find the gen proguard rule file at build/intermediates/bugly_intermediates/bugly_proguard.pro
and we will help you to put it in the proguardFiles.

if enableProxyApplication is true
we will replace you real application to TINKER_PATCH_APPLICATION

if autoGenerateTinkerId is true
we will auto set base tinkerId as versionName.versionCode, like 1.0.1
-----------------------------------------------------------------
------ Tinker Support Override tinkerPatch Configuration ------
tinkerPatch {
    tinkerEnable = true
    oldApk = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release.apk
    ignoreWarning = false
    useSign = true
    buildConfig {
        applyMapping = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release-mapping.txt
        applyResourceMapping = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release-R.txt
        tinkerId = base-1.0.1
        keepDexApply = false
        isProtectedApp = false
        supportHotplugComponent = true
    }
    dex {
        dexMode = jar
        pattern = [classes*.dex, assets/secondary-dex-?.jar]
        loader = [com.tencent.tinker.loader.*]
    }
    lib {
         pattern = [lib/*/*.so]
    }
    res {
         pattern = [res/*, r/*, assets/*, resources.arsc, AndroidManifest.xml]
         ignoreChange = [assets/*_meta.txt]
         largeModSize = 100
    }
    packageConfig {
    }
    sevenZip {
         zipArtiface = com.tencent.mm:SevenZip:1.1.10
         path =
    }
------ End ------
variantName:Debug
outputVariantName:Debug

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > No such property: variantConfiguration for class: com.android.build.gradle.internal.variant.ApplicationVariantData
   > can't find tinkerProcessDebugManifest, you must init tinker plugin first!

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

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

BUILD FAILED in 336ms
10:40:30: Task execution finished 'dependencies'.


project添加依赖后,build报错如下:

10:43:36: Executing task 'dependencies'...

Executing tasks: [dependencies] in project E:\Kotlin\HotFix


> Configure project :app
TinkerSupport Plugin Version: 1.1.4
    Requires:
        Android Plugin for Gradle, Revision 2.0.0 or higher
    Dependencies:
        Gradle 2.10 or higher (Current Gradle Version: 6.1.1)

apply plugin: 'com.tencent.tinker.patch'
----------------------tinker build warning ------------------------------------
tinker auto operation:
excluding annotation processor and source template from app packaging. Enable dx jumboMode to reduce package size.
enable dx jumboMode to reduce package size.
disable preDexLibraries to prevent ClassDefNotFoundException when your app is booting.
disable archive dex mode so far for keeping dex apply.

tinker will change your build configs:
we will add TINKER_ID=null in your build output manifest file build/intermediates/manifests/full/*

if minifyEnabled is true
you will find the gen proguard rule file at build/intermediates/tinker_intermediates/tinker_proguard.pro
and we will help you to put it in the proguardFiles.

if multiDexEnabled is true
you will find the gen multiDexKeepProguard file at build/intermediates/tinker_intermediates/tinker_multidexkeep.pro
and we will help you to put it in the MultiDexKeepProguardFile.

if applyResourceMapping file is exist
we will build app apk with resource R.txt file
if resources.arsc has changed, you should use applyResource mode to build the new apk!
-----------------------------------------------------------------
----------------------tinker-support build warning ------------------------------------
if you not set autoBackupApkDir we will auto backup the build file to E:\Kotlin\HotFix\app/tinker.

if overrideTinkerPatchConfiguration is true
we will override tinker patch configuration��you must use tinker-support's configuration

you will find the gen proguard rule file at build/intermediates/bugly_intermediates/bugly_proguard.pro
and we will help you to put it in the proguardFiles.

if enableProxyApplication is true
we will replace you real application to TINKER_PATCH_APPLICATION

if autoGenerateTinkerId is true
we will auto set base tinkerId as versionName.versionCode, like 1.0.1
-----------------------------------------------------------------
------ Tinker Support Override tinkerPatch Configuration ------
tinkerPatch {
    tinkerEnable = true
    oldApk = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release.apk
    ignoreWarning = false
    useSign = true
    buildConfig {
        applyMapping = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release-mapping.txt
        applyResourceMapping = E:\Kotlin\HotFix\app\build\bakApk/app-0208-15-10-00/app-release-R.txt
        tinkerId = base-1.0.1
        keepDexApply = false
        isProtectedApp = false
        supportHotplugComponent = true
    }
    dex {
        dexMode = jar
        pattern = [classes*.dex, assets/secondary-dex-?.jar]
        loader = [com.tencent.tinker.loader.*]
    }
    lib {
         pattern = [lib/*/*.so]
    }
    res {
         pattern = [res/*, r/*, assets/*, resources.arsc, AndroidManifest.xml]
         ignoreChange = [assets/*_meta.txt]
         largeModSize = 100
    }
    packageConfig {
    }
    sevenZip {
         zipArtiface = com.tencent.mm:SevenZip:1.1.10
         path =
    }
------ End ------
variantName:Debug
outputVariantName:Debug

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > No such property: variantConfiguration for class: com.android.build.gradle.internal.variant.ApplicationVariantData
   > can't find tinkerProcessDebugManifest, you must init tinker plugin first!

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

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

BUILD FAILED in 518ms
10:43:37: Task execution finished 'dependencies'.





# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

这是app.gradle的代码:

apply plugin: 'com.android.application'

android {
   compileSdkVersion 30
   buildToolsVersion "30.0.2"

   defaultConfig {
       applicationId "com.example.hotfixfirsttest"
       minSdkVersion 21
       targetSdkVersion 30
       versionCode 1
       versionName "1.0"
       ndk {
           //设置支持的SO库架构
           abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
       }
       testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
   }

   buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
       }
   }
}

dependencies {
   implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
   implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'androidx.test.ext:junit:1.1.2'
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
   implementation "com.android.support:multidex:1.0.1" // 多dex配置
   //注释掉原有bugly的仓库
   //compile 'com.tencent.bugly:crashreport:latest.release'//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.3.4
  implementation 'com.tencent.bugly:crashreport_upgrade:1.3.6'
   // 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
 implementation 'com.tencent.tinker:tinker-android-lib:1.9.9'
   implementation 'com.tencent.bugly:nativecrashreport:latest.release' //其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
}
// 依赖插件脚本
apply from: 'tinker-support.gradle'


这是Project.build的代码

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
   repositories {
       google()
jcenter()
}
   dependencies {
       classpath "com.android.tools.build:gradle:4.0.0"
           // tinkersupport插件, 其中lastest.release指拉取最新版本,也可以指定明确版本号,例如1.0.4
           classpath "com.tencent.bugly:tinker-support:1.1.5"

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


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕雪 2020-12-30 11:46:01

同学,你好。你当前的gradle太低了,但也不可用太高的,建议​项目的build.gradle要用classpath 'com.android.tools.build:gradle:3.0.1'版本就可以了。热修复,插件化这些技术都比较依赖gradle,属于中国市场的黑科技 。另外测试机,也不用要太高的版本,不要超过8.0的。祝学习愉快!

  • 提问者 慕运维0750787 #1
    classpath

    设置的是gradle plug吧?

    2021-01-05 15:19:11
  • 提问者 慕运维0750787 #2
    gradle3.0.1下载成功但是gralde插件2.6总是失败,说获取资源失败,我想应该是不存在这个版本吧(或者名称不确切),改成插件2.3下载成功。这样不会影响吧?
    2021-01-05 16:13:12
  • 好帮手慕雪 回复 提问者 慕运维0750787 #3
    嗯,没错。是的
    2021-01-05 16:23:43
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师