关于Android studio 4.1 的模板代码插件的方案以及遇到的坑

背景

众所周知,android studio 4.1后旧的模板代码已经不支持生成了,但还是有解决方案的

具体怎么做,已经有大佬给出方案了。看这里

AndroidStudio4.1 自定义模板 | 亿特博客

遇到的问题

1、编译报错

。。。。。。
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.1.6.
Required by:
    project : > org.jetbrains.intellij:org.jetbrains.intellij.gradle.plugin:1.1.6
Caused by: org.gradle.internal.component.NoMatchingConfigurationSelectionException: No matching variant of org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.1.6 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.0.2' but:
  - Variant 'apiElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.1.6 declares a library, packaged as a jar, and its dependencies declared externally:
      - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
      - Other compatible attribute:
          - Doesn't say anything about org.gradle.plugin.api-version (required '7.0.2')
  - Variant 'runtimeElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.1.6 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
      - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
      - Other compatible attribute:
          - Doesn't say anything about org.gradle.plugin.api-version (required '7.0.2')
。。。。。。

暴力解决:将build.gradle.kts 下的 "org.jetbrain.intellij"插件降级为1.0

2、 插件导入错误

提示 “Plugin ‘XX‘ is incompatible with this installation”

原因:插件不支持,这个问题是不是该插件支持的ide版本来安装插件时报的错

解决方案:支持一下ide版本就好了,修改根目录下的gradle.properties的pluginSinceBuild版本即可。

详细的版本说明:

https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions

查看自己的android studio 版本 

3、插件导入后重启右下角红色感叹号报错

 报错信息:

Exception in thread "main" java.lang.UnsupportedClassVersionError: 
com/baeldung/MajorMinorApp has been compiled by a more recent version of the Java 
Runtime (class file version 55.0), this version of the Java Runtime only recognizes 
class file versions up to 52.0

问题原因:插件编译jdk版本为55(jdk11),需要统一成52(jdk1.8),我们使用的模板项目中1.0将jdk更新到了11

(https://github.com/JetBrains/intellij-platform-plugin-template/releases)

我的解决方案是把0.10版本的clone下来,然后基于0.10版本去开发。 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值