New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
com.android.tools.build:gradle:4.0.2出现的问题 #7
Comments
我也遇到了这个问题,应该是4.x后的插件版本API发生了变更。 |
AGP 4.1 API 的改变还是比较大了 |
用反射的方式获取 DelegatingClassLoader 和 variantManager API object ReflectionUtils {
fun getDeclaredField(obj: Any, fieldName: String): Field? {
var clazz: Class<*> = obj.javaClass
while (clazz != Any::class.java) {
try {
return clazz.getDeclaredField(fieldName)
} catch (e: Exception) {
}
clazz = clazz.superclass
}
return null
}
/**
* 直接读取对象的属性值, 忽略 private/protected 修饰符, 也不经过 getter
* @param object : 子类对象
* @param fieldName : 父类中的属性名
* @return : 父类中的属性值
*/
fun getFieldValue(obj: Any, fieldName: String): Any? {
//根据 对象和属性名通过反射 调用上面的方法获取 Field对象
val field: Field? = getDeclaredField(obj, fieldName)
field?.isAccessible = true
try {
//获取 object 中 field 所代表的属性值
return field?.get(obj)
} catch (e: Exception) {
e.printStackTrace()
}
return null
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unable to find method 'com.android.build.gradle.AppPlugin.getVariantManager()Lcom/android/build/gradle/internal/VariantManager;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
The text was updated successfully, but these errors were encountered: