While I run the project with an implementation project(path: ':rocket_library') then the resource (Ex: R.color.color_rocket_web) file works fine. But after building the JAR file and include the JAR with project resource not found. Is it possible to attach the resource files in a JAR?
The color not found from the project:
Library code: On runtime also not found from Libray.
import infix.imrankst1221.rocket.library.R
fun getThemePrimaryColor(mContext : Context): Int {
return PreferenceUtils.getInstance().getIntegerValue(Constants.KEY_COLOR_PRIMARY, ContextCompat.getColor(mContext, R.color.my_color))
}
Runtime exception:
java.lang.NoClassDefFoundError: Failed resolution of: Linfix/imrankst1221/rocket/library/R$color;
at infix.imrankst1221.rocket.library.utility.UtilMethods.getThemePrimaryColor(UtilMethods.kt:65)
at infix.imrankst1221.codecanyon.ui.splash.SplashActivity.onCreate(SplashActivity.kt:30)
Caused by: java.lang.ClassNotFoundException: Didn't find class "infix.imrankst1221.rocket.library.R$color" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/infix.imrankst1221.rocket.web-_mlMdyx2A0UqLZig9zkW5Q==/base.apk"],nativeLibraryDirectories=[/data/app/infix.imrankst1221.rocket.web-_mlMdyx2A0UqLZig9zkW5Q==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
Library Build.Gradle:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main {
res.srcDirs = ['src/main/res']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.browser:browser:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation 'com.google.code.gson:gson:2.8.5'
}
task createJar(type: Copy) {
from('build/intermediates/packaged-classes/release/')
into('libs/')
include('classes.jar')
rename('classes.jar', 'rocket_web.jar')
}