(https://i.sstatic.net/Ax6k4y8J.png)(https://i.sstatic.net/H37cYV5O.png)
In my Android studio project, I need to use framework.jar, but I found that the Java files in the project uses framework.jar, while Kotlin uses android. jar
build.gradle
dependencies {
//implementation files('libs/framework.jar')
api files('libs/framework.jar')
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation platform('androidx.compose:compose-bom:2023.08.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
}
preBuild {
def fileName = project.parent.name + "." + project.name + ".main.iml"
def imlFile = file("$rootProject.rootDir/.idea/modules/app/$fileName")
println('Change ' + imlFile.path + ' order')
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
new groovy.util.Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (FileNotFoundException e) {
}
}
I modified the priority of the SDK in the IML file in the build.gradle file, which seems to only be valid for Java files. How to make the kotlin file also prioritize framewor.jar?
New contributor
123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.