首页 > 解决方案 > 如何从奥利奥版本降级到棉花糖?

问题描述

我的应用程序需要在 Android 6.0 上运行它实际上是版本 8 我在我的 gradle 属性中更改了配置

也不能改变我的编译版本它不起作用......

android { compileSdkVersion 29 buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "com.axem.rfid"
    minSdkVersion 23
    targetSdkVersion 26
    versionCode 29
    versionName "1.0.1"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

但是我的应用程序仍然无法在设备上运行并且我没有收到任何错误我认为我的活动可能有问题

   @SuppressLint("MissingPermission")
fun doAfterPermission() {
    initAxemRoot()
    when (FileUtils.readConfigFile().parseRes) {
        FileUtils.CONFIG_FILE_EXIST_MALFORMED -> Toast.makeText(
            applicationContext,
            getString(R.string.config_file_malformed),
            Toast.LENGTH_LONG
        ).show()
        FileUtils.CONFIG_FILE_NOT_FOUND -> Toast.makeText(
            applicationContext,
            getString(R.string.config_file_not_found),
            Toast.LENGTH_LONG
        ).show()
    }
    splashViewModel.checkLicence(Build.getSerial(), this)
}

因此,如果您能提供帮助,将不胜感激,谢谢!

标签: androidandroid-studiokotlinmigrationversion

解决方案


我在这里解决我的问题我的代码(如果它可以帮助某人):

 fun hasPermissions(context: Context, vararg permissions: String): Boolean = permissions.all {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O){
        splashViewModel.checkLicence(Build.SERIAL, this)
    }
    ActivityCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED
}

推荐阅读