Я новичок в Hilt и ломаю голову над тем, как реализовать его в своем многомодульном приложении. После бесконечных попыток ошибка сборки варьируется от «ошибки a» до «ошибки b», затем «ошибки c» и так далее.
Вот как я начал внедрять Hilt в свой многомодульное приложение:
plugins {
id('dagger.hilt.android.plugin')
id('com.android.application')
id('kotlin-android')
id('kotlin-kapt')
}
android {
compileSdkVersion 32
def code
Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists())
versionProps.load(new FileInputStream(versionPropsFile))
code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
packagingOptions {
resources {
pickFirsts += ['META-INF/LICENSE.txt']
excludes += ['META-INF/NOTICE.md', 'META-INF/LICENSE.md', 'META-INF/INDEX.LIST', 'META-INF/DEPENDENCIES', 'META-INF/io.netty.versions.properties']
}
}
defaultConfig {
applicationId 'com.xxx.xxx'
minSdkVersion 23
targetSdkVersion 32
versionCode code
versionName "2.0." + code
// next ndk abifilters have to be disabled if spli apk is enabled.
// ndk.abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'//testing
multiDexEnabled true
compileOptions {
sourceCompatibility java_version
targetCompatibility java_version
}
}
compileOptions {
sourceCompatibility java_version
targetCompatibility java_version
}
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "armeabi-v7a"
include "arm64-v8a"
include "x86"
include "x86_64"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
buildTypes {
release {
/*signingConfig signingConfigs.release*/
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// This next piece of code is used by apk Split
applicationVariants.all { variant ->
variant.outputs.all { output ->
project.ext { appName = 'xxx' }
def newName = 'xxx_' + output.getFilter(com.android.build.OutputFile.ABI) + '.apk'
outputFileName = new File("./", newName)
}
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
//project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000 + android.defaultConfig.versionCode
project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) * 1000 + code - 1000
}
}
}
debug {
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
def androidHome = System.getenv("ANDROID_HOME")
maven {
url "$androidHome/extras/android/m2repository/"
}
maven {
url "https://maven.java.net/content/groups/public/"
}
}
/*tasks.withType(JavaCompile) {
options.compilerArgs
Подробнее здесь: [url]https://stackoverflow.com/questions/73044297/android-kotlin-hilt-error-building-project[/url]
Я новичок в Hilt и ломаю голову над тем, как реализовать его в своем многомодульном приложении. После бесконечных попыток ошибка сборки варьируется от «ошибки a» до «ошибки b», затем «ошибки c» и так далее. Вот как я начал внедрять Hilt в свой [b]многомодульное[/b] приложение: [code]Project build.gradle:
android { compileSdkVersion 32 def code Properties versionProps = new Properties() def versionPropsFile = file('version.properties') if (versionPropsFile.exists()) versionProps.load(new FileInputStream(versionPropsFile)) code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1 versionProps['VERSION_CODE'] = code.toString() versionProps.store(versionPropsFile.newWriter(), null) packagingOptions { resources { pickFirsts += ['META-INF/LICENSE.txt'] excludes += ['META-INF/NOTICE.md', 'META-INF/LICENSE.md', 'META-INF/INDEX.LIST', 'META-INF/DEPENDENCIES', 'META-INF/io.netty.versions.properties'] } } defaultConfig { applicationId 'com.xxx.xxx' minSdkVersion 23 targetSdkVersion 32 versionCode code versionName "2.0." + code // next ndk abifilters have to be disabled if spli apk is enabled. // ndk.abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'//testing multiDexEnabled true compileOptions { sourceCompatibility java_version targetCompatibility java_version } } compileOptions { sourceCompatibility java_version targetCompatibility java_version } splits { // Configures multiple APKs based on ABI. abi { // Enables building multiple APKs per ABI. enable true // By default all ABIs are included, so use reset() and include to specify that we only // want APKs for x86 and x86_64. // Resets the list of ABIs that Gradle should create APKs for to none. reset() // Specifies a list of ABIs that Gradle should create APKs for. include "armeabi-v7a" include "arm64-v8a" include "x86" include "x86_64" // Specifies that we do not want to also generate a universal APK that includes all ABIs. universalApk false } } buildTypes { release { /*signingConfig signingConfigs.release*/ minifyEnabled false shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // This next piece of code is used by apk Split applicationVariants.all { variant -> variant.outputs.all { output -> project.ext { appName = 'xxx' } def newName = 'xxx_' + output.getFilter(com.android.build.OutputFile.ABI) + '.apk' outputFileName = new File("./", newName) } // assign different version code for each output variant.outputs.each { output -> output.versionCodeOverride = //project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000 + android.defaultConfig.versionCode project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) * 1000 + code - 1000 } } } debug { } } allprojects { repositories { jcenter() mavenCentral() def androidHome = System.getenv("ANDROID_HOME") maven { url "$androidHome/extras/android/m2repository/" } maven { url "https://maven.java.net/content/groups/public/" } } /*tasks.withType(JavaCompile) { options.compilerArgs