Android Robust Cannot cast object *** with class *** to class

版权声明:1、本BLOG的目的、形式及内容。   此BLOG为个人维护BLOG,内容均来自 原创及互连网转载。最终目的为收集整理自己需要的文章技术等内容,不涉及商业用途。\r\n 2、有关原创文章的版权   本BLOG上原创文章未经本人许可,不得用于商业用途及传统媒体。网络媒体转载请注明出处,否则属于侵权行为。\r\n 3、有关本站侵权   本BLOG所转载的内容,均是本人未发现有对文章版权声明的文章且 https://blog.csdn.net/shijianduan1/article/details/85252096

转载请申明,本文来自:https://blog.csdn.net/shijianduan1/article/details/85252096


问题:

Cannot cast object 'com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact@7599177f'
 with class 'com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact'
  to class 'org.gradle.api.file.FileCollection'


***************** 12.26更新 ************************
添加签名后还是报错了, 这次仔细排查了下,查看了详细的编译log,

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':robust:packageRelease'.
> Cannot cast object 'com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact@b88330b' with class 'com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact' to class 'org.gradle.api.file.FileCollection'

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s

分析:
1. log中提示 与Gradle5.0 不兼容
2. 重新编译了下,发现debug 可以顺利通过,release失败
3.Github:Robust 官方代码查看了下,用的是gradle 2.1编译的, 官方说明是 “Gradle 2.10+ , include 3.0” ,而我本地的是gradle3.2.1

结果:
1. 不知道是不是 分析3 中, 本地gradle版本太高不兼容导致的


***************** 12.25更新 (以下方法没用)***************
解决方案:
应用没有签名,添加签名即可

示例:
1.每次手动点击 build – generate signed bundle/apk
2.在app的build.gradle中配置下面

android {
    signingConfigs {
        main {
 			File key = new File("路径")   //如果是在根目录下,"../签名.jks"
           		 keyAlias "别名"
          		  keyPassword "密码"
         		   storeFile file(key)
          		  storePassword "密码"
              }
        }
  buildTypes {
        release {
            signingConfig signingConfigs.main
        }
        debug {
            signingConfig signingConfigs.main
        }
    }
}  

猜你喜欢

转载自blog.csdn.net/shijianduan1/article/details/85252096