Hi there,
I have an annoying problem. In a mix Android project (Kotlin and Java ) I have made a new Kotlin fragment class but I got ClassNotFoundException only prior to android 5. In the first I thought it was a multidex problem that the Koltin fragment class was not added to the primary dex (The app was exceeding the 64K method). I tried to put this desired fragment class in the primary dex using dexConfig but it did not work as well. I found that app was exceeding the limit a little bit so I removed some dependencies and avoid to use mulidex but unfortunately the problem still happens. When replacing this fragment which is written in Kotlin with a Java one the problem was resolved.
I wish anyone can help me…
Thanks for this great language.
Here is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = ‘1.2.0’
repositories {
jcenter()
// You need to add the following repository to download the
// new plugin.
google()
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.0.0’
classpath ‘com.google.gms:google-services:3.1.1’
classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version”
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'http://sdk.uxcam.com/android/' }
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
android {
signingConfigs {
config {
keyAlias 'menassah'
keyPassword 'EAlQDthF0uZeygfjv6pK'
storePassword '7F-K>[rUiZ'
storeFile file('./Users/Innovolve')
}
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
compileSdkVersion 26
buildToolsVersion '26.0.3'
defaultConfig {
applicationId "com.innovolve.iqraaly"
minSdkVersion 16
targetSdkVersion 22
versionCode 84
versionName "2.4.1.39"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
dexOptions {
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.config
debuggable false
jniDebuggable false
renderscriptDebuggable false
shrinkResources true
buildConfigField 'boolean', 'CRASHLYTICS_ON', 'true'
buildConfigField 'boolean', 'TESTFAIRY_ON', 'false'
buildConfigField("String", "BASE_URL", "\"http://mobile.iqraaly.com/api/\"")
}
debug {
debuggable true
signingConfig signingConfigs.config
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
buildConfigField 'boolean', 'CRASHLYTICS_ON', 'false'
buildConfigField 'boolean', 'TESTFAIRY_ON', 'true'
buildConfigField("String", "BASE_URL", "\"http://mobile.iqraaly.com/api/\"")
}
// Save TestFairy key
buildTypes.each {
it.buildConfigField("String", "TESTFAIRY_KEY", "\"ef8ca53e09a6cccedf5066fcabf3d27b57a4905e\"")
}
}
flavorDimensions "default"
productFlavors {
paid {
applicationId "com.innovolve.iqraaly"
dimension "default"
}
free {
applicationId "com.innovolve.iqraaly"
dimension "default"
}
}
sourceSets {
free {
res.srcDirs = ['src/free/res']
java.srcDirs = ['src/free/java']
main.java.srcDirs += 'src/main/kotlin'
}
paid {
res.srcDirs = ['src/paid/res']
java.srcDirs = ['src/paid/java']
main.java.srcDirs += 'src/main/kotlin'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildscript {
repositories {
maven { url 'http://sdk.uxcam.com/android/' }
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
dependencies {
implementation project(':iqraalySDK')
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true
}
implementation files('libs/testfairy-android-sdk-1.5.2.jar')
// If you want to use the GPU Filters
implementation 'org.jraf:android-switch-backport:2.0.1'
implementation 'com.facebook.android:facebook-android-sdk:4.28.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'com.android.support:mediarouter-v7:26.1.0'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.android.support:multidex:1.0.2'
implementation 'tk.zielony:carbon:0.15.0.1'
implementation 'jp.wasabeef:picasso-transformations:2.1.2'
implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
implementation 'com.github.vivchar:ViewPagerIndicator:v1.0.1'
implementation 'com.twotoasters.jazzylistview:library:1.2.1'
implementation 'com.athkalia.emphasis:emphasis:0.4'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
implementation 'com.google.android.gms:play-services:11.6.2'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.uxcam:uxcam:2.6.2@aar'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'