今天打包一個項目,突然報個錯,讓人摸不到問題所在。這個項目是java開發的。
/Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.20/9be77b243a362b745e365f286627b8724337009c /kotlin-stdlib-1.4.20.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5
w: Runtime JAR files in the classpath have the version 1.4, which is older than the API version 1.5.
Consider using the runtime of version 1.5, or pass '-api-version 1.4' explicitly to restrict
the available APIs to the runtime of version 1.4. You can also pass '-language-version 1.4' instead,
which will restrict not only the APIs to the specified version, but also the language features
看了提示,應該是jar包版本的問題。
但問題肯定出在:
kotlin-stdlib
哪應該如何解決呢?
應該是無意當中用到了kotlin寫的包了,所以打包編譯的時候,會用到這個依賴,但是沒有指定,那只能用系統自帶的,但是kotlin已經升級為最新版本。
1、增加classpath : build.gradle(project:xxxx)
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
2、增加 dependencies: build.gradle(project:xxxx.app)
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'
其中:xxxx您的項目名稱。
以上二步基本上解決了上面的報錯,如果還有報錯,看一下提示,解決即可。
在這里,缺少布局中的一個屬性沒有,默認生成了不同設備的文件導致。
將其它的v24,land,如果用不到,刪除就可以解決。