ПОЧЕМУ ЛЮБОЙ ЛЮДЬ НЕ ПОКАЖЕТ МНЕ ???
В моем приложении я должен реализовать зависимость MultiDex , и я добавил это в файл gradle.build и записать некоторые коды в приложение class
!
Но после запуска приложения покажите принудительное закрытие ошибка и не запущенное приложение!
gradle.build:
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:multidex-instrumentation:1.0.3'
Класс BaseActivity:
abstract class BaseActivity : AppCompatActivity() {
/**
* Set your page layout when initialize `layoutId`, Ex. R.layout.activity_main
*/
abstract var layoutId: Int
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(layoutId)
}
/**
* With below method, we can set custom font to all of activities
*/
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase))
}
}
Класс применения:
import android.app.Activity
import android.app.Application
import android.content.Context
import android.os.Bundle
import androidx.multidex.MultiDex
import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig
import com.adjust.sdk.LogLevel
import com.app.android.R
import com.app.android.utils.ADJUST_APP_TOKEN
import com.crashlytics.android.Crashlytics
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.ContentViewEvent
import com.google.android.gms.analytics.GoogleAnalytics
import com.google.android.gms.analytics.HitBuilders
import com.google.android.gms.analytics.Tracker
import io.fabric.sdk.android.Fabric
import io.github.inflationx.calligraphy3.CalligraphyConfig
import io.github.inflationx.calligraphy3.CalligraphyInterceptor
import io.github.inflationx.viewpump.ViewPump
class App : Application() {
private var adjustEnvironment: String = ""
private lateinit var adjustConfig: AdjustConfig
private lateinit var analytics: GoogleAnalytics
private lateinit var tracker: Tracker
override fun onCreate() {
super.onCreate()
//Calligraphy
ViewPump.init(
ViewPump.builder().addInterceptor(
CalligraphyInterceptor(
CalligraphyConfig.Builder().setDefaultFontPath("fonts/IranSans.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
)
).build()
)
//GoodPres
GoodPrefs.init(applicationContext)
//Fabric initialize kits
val fabric = Fabric.Builder(this)
.kits(Answers())
// .kits(Crashlytics())
.debuggable(true)
.build()
Fabric.with(fabric)
//Adjust
adjustEnvironment = AdjustConfig.ENVIRONMENT_PRODUCTION
adjustConfig = AdjustConfig(this, ADJUST_APP_TOKEN, adjustEnvironment, true)
adjustConfig.setSendInBackground(true)
adjustConfig.setLogLevel(LogLevel.SUPRESS)
Adjust.onCreate(adjustConfig)
registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks())
//Google Analytics
analytics = GoogleAnalytics.getInstance(this)
}
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this)
}
//Adjust lifecycle method
private class AdjustLifecycleCallbacks : Application.ActivityLifecycleCallbacks {
override fun onActivityResumed(activity: Activity) {
Adjust.onResume()
}
override fun onActivityPaused(activity: Activity) {
Adjust.onPause()
}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle) {}
override fun onActivityStarted(activity: Activity) {}
}
@Synchronized
fun getDefaultTracker(): Tracker {
if (tracker == null) {
tracker = analytics.newTracker(R.xml.global_tracker)
}
return tracker
}
fun anserTracker(name: String, type: String, id: String) {
Answers.getInstance().logContentView(
ContentViewEvent()
.putContentName(name)
.putContentType(type)
.putContentId(id)
)
}
fun googleTracker(category: String, action: String, label: String) {
val tracker: Tracker = getDefaultTracker()
tracker.send(
HitBuilders.EventBuilder()
.setCategory(category)
.setAction(action)
.setLabel(label)
.build()
)
}
Сообщение об ошибке:
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState
at com.app.android.ui.App$AdjustLifecycleCallbacks.onActivityCreated(Unknown Source:7)
at android.app.Application.dispatchActivityCreated(Application.java:221)
at android.app.Activity.onCreate(Activity.java:1071)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:147)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:317)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)
at com.app.android.ui.base.BaseActivity.onCreate(BaseActivity.kt:16)
Показать ошибку для этой строки: import androidx.multidex.MultiDex
Как я могу исправить эту проблему?