Closed lukehutch closed 5 days ago
I can't reproduce this error.
$ flutter --version
Flutter 3.22.0-0.3.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 87b652410d (13 days ago) • 2024-04-23 21:41:18 -0500
Engine • revision b4bfd45986
Tools • Dart 3.4.0 (build 3.4.0-282.3.beta) • DevTools 2.34.3
$ flutter create reproduce1119 --platform=android
$ cd reproduce1119
$ flutter pub add cronet_http
$ flutter run
At least for a new project minSdk
and other parameters are set to match Flutter's gradle plugin located in $flutterSdkPath/packages/flutter_tools/gradle
:
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
The default values are defined here.
I could change the minSdkVersion
to 21 since it's the same as Flutter, but logically shouldn't it just be the maximum across all the dependencies including your application? So if your application is using current Flutter's default, then it should set it to 21 anyways?
Also, do you have ndkVersion = flutter.ndkVersion
in your app/build.gradle? Maybe that downloads the correct NDK version automatically. Otherwise you could download an NDK from Android Studio and see if you still get this error.
Alternatively I could add ndkVersion = android.ndkVersion
to package:jni
's build.gradle. I'll try removing every NDK on my machine to see if this has an effect on auto downloading...
Prior design doc about this by @dcharkes: http://flutter.dev/go/android-ndk-version
The error is on Flutter beta and master channels, and the issue is they are now starting to warn that linking with NDK projects that are compatible with NDK versions lower than 21 may break things moving forward. It's an error, not a warning, and it stops the build unless you provide the specified override option to suppress it.
No, providing ndkVersion = android.ndkVersion
and/or ndkVersion = flutter.ndkVersion
does not solve the problem.
In the meantime, a dirty hack to add in android/build.gradle
:
subprojects {
...
afterEvaluate { project ->
if (project.name.equalsIgnoreCase('jni')
&& project.hasProperty('android')) {
android {
defaultConfig {
minSdkVersion 21
}
}
}
}
}
OK, I'll publish jni 0.9.2 with minSdk 21
.
I upgraded Flutter to the most recent beta, and now
cronet_http
, which depends uponjni ^0.7.3
as a transitive dependency, causes my project to no longer build:These lines seem relevant:
https://github.com/dart-lang/native/blob/95d226d290d4d5c583c4e45b04048442f244c656/pkgs/jni/android/build.gradle#L59C1-L64C33
and
https://github.com/dart-lang/native/blob/95d226d290d4d5c583c4e45b04048442f244c656/pkgs/jni/android/build.gradle#L87
This needs to be bumped to 21 to solve the problem. (Also now
minSdkVersion
has becomeminSdk
.)