Skip to content

Commit

Permalink
fix: "can't find referenced class" caused by desugaring
Browse files Browse the repository at this point in the history
* 🔨 Pass local configuration to D8 execution

* 🔨 Specify minimum SDK for the bytecode is being generated
  • Loading branch information
hammerhai authored and shreyashsaitwal committed Jan 11, 2024
1 parent d3d34b6 commit 792d810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/src/commands/build/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class BuildCommand extends Command<int> {

_lgr.startTask('Generating DEX bytecode');
try {
await Executor.execD8(artJarPath);
await Executor.execD8(config, artJarPath);
} catch (e, s) {
_catchAndStop(e, s);
return 1;
Expand Down
4 changes: 3 additions & 1 deletion lib/src/commands/build/tools/executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class Executor {
static final _libService = GetIt.I<LibService>();
static final _processRunner = ProcessRunner();

static Future<void> execD8(String artJarPath) async {
static Future<void> execD8(Config config, String artJarPath) async {
final args = <String>[
...['-cp', await _libService.r8Jar()],
'com.android.tools.r8.D8',
...['--min-api', '${config.minSdk}'],
...[
'--lib',
p.join(_fs.libsDir.path, 'android-$androidPlatformSdkVersion.jar')
Expand Down Expand Up @@ -134,6 +135,7 @@ class Executor {
...['--input', '\'$artJarPath\''],
...['--output', '\'${outputJar.path}\''],
...classpathJars.map((dep) => '--classpath_entry' '\n' '\'$dep\''),
...['--min_sdk_version', '${config.minSdk}'],
];
final argsFile =
p.join(_fs.buildFilesDir.path, 'desugar.args').asFile(true);
Expand Down

0 comments on commit 792d810

Please sign in to comment.