Я создавал приложение Flutter в приложении Android, все работало нормально, как только я использовал GeoLocator Library, мое приложение зависло, заявив, что оно несовместимо с AndroidX. Когда я пытаюсь перенести мой код в AndroidX, он говорит: «Вам необходимо установить compiledSDK по крайней мере на 28 в вашем модуле build.gradle для перехода на AndroidX. Я уже установил его на 28, но он все равно не работает.
Чтобы решить эту проблему. Я пробовал все шаги, упомянутые в документации Flutter.
Ссылка: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
1. In android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
2. In android/build.gradle, replace:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
by
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
3. In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
4.In android/app/build.gradle:
Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28
5.Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes:
In android/app/build.gradle
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
by
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Finally, under dependencies {, replace
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
by
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Это мой файл build.grade, в котором я установил версию SDK:
enter code here compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "co.appbrewery.clima"
minSdkVersion 28
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Попробовал все вышеперечисленное, по-прежнему получая сообщение об ошибке, при котором версия SDK менялась по крайней мере на 28, когда я пытался установить его. Перейдите на Android X с помощью функции Android Studio.