trevjonez / composer-gradle-plugin

Gradle task type and plugin for interacting with https://github.com/gojuno/composer
Apache License 2.0
53 stars 18 forks source link

Issue Cannot parse package #51

Open matkt opened 5 years ago

matkt commented 5 years ago

With the latest version of the plugin and even the previous versions I always have this error when launching the tests

Task :test-framework:testDebugComposer FAILED [Thu Jul 11 10:37:37 CEST 2019]: Cannot parse test package from aapt dump badging $APK output.

trevjonez commented 5 years ago

This is actually going to be an issue for composer issue. I make no effort to use AAPT to parse package info in the plugin because the plugin can pull it directly from the data model that produces the APK.

It seems that if arguments for package name are sent to composer is should skip trying to parse them from the APK?

Im going to close for now and urge you open the issue with the composer repo directly.

rocboronat commented 3 years ago

In case someone arrived here as I did, I did open an issue in composer with exactly this very issue: https://github.com/gojuno/composer/issues/180

trevjonez commented 3 years ago

Happy to see a PR on this if someone wants to take a swing at it.

trevjonez commented 3 years ago

Given that I don't publish a fat jar of composer, is this even still a valid usecase?

b-demuth commented 2 years ago

I hit a similar issue today, manifesting itself with the error message "Cannot parse test package from aapt dump badging $APK output." as well. After remote debugging composer, it turned out that this was caused by the String "package" being contained in the absolute path of my working directory.

The way that Composer parses the aapt output file is not very robust, it looks like this:

output.readText()
      .split(System.lineSeparator())
      // output format `package: name='$testPackage' versionCode='' versionName='' platformBuildVersionName='xxx'`
      .firstOrNull { it.contains("package") }
      ?.split(" ")
      ?.firstOrNull { it.startsWith("name=") }
      ?.split("'")
      ?.getOrNull(1)
      ?.let(TestPackage::Valid)
      ?: TestPackage.ParseError("Cannot parse test package from `aapt dump badging \$APK` output.")

Since the second line of the aapt output file echoes the executed aapt command including the absolute path of the examined test.apk, the above code misread this line and expected it to contain the package name which it didn't.