Skip to content

DebugProbesKt.bin gets shipped in release apk #2274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
G00fY2 opened this issue Sep 29, 2020 · 8 comments
Closed

DebugProbesKt.bin gets shipped in release apk #2274

G00fY2 opened this issue Sep 29, 2020 · 8 comments
Labels

Comments

@G00fY2
Copy link

G00fY2 commented Sep 29, 2020

Not a big deal, but I am wondering if the Android build process should really add this to every release APK (gets placed into the root folder).

Tested with Android Studio 4.0.1 and 4.2.0 Canary 12 using the latest Kotlin and Coroutines Android plugins/libraries.

As a workaorund it should be safe to use

packagingOptions {
  exclude 'DebugProbesKt.bin'
}

for release builds, right?

@elizarov
Copy link
Contributor

Yes. It is safe to exclude. I wonder if we can also add the corresponding exclusion options directly to the library. Is it even possible?

dkhalanskyjb added a commit that referenced this issue Oct 6, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 6, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 9, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 9, 2020
)

Added instructions to work around #2023 
Also, the answer to #2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
@qwwdfsad
Copy link
Collaborator

Fixed by providing how-to documentation in 1.4.0

@G00fY2
Copy link
Author

G00fY2 commented Nov 12, 2020

For everyone reading this issue, this was added to the README.

recheej pushed a commit to recheej/kotlinx.coroutines that referenced this issue Dec 28, 2020
…tlin#2288)

Added instructions to work around Kotlin#2023 
Also, the answer to Kotlin#2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this issue Dec 28, 2020
…tlin#2288)

Added instructions to work around Kotlin#2023 
Also, the answer to Kotlin#2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
@bubenheimer
Copy link

@qwwdfsad Can you clarify the how-to instructions, please? They are hard to actually understand and follow. They say "no loss of functionality", but it would appear that I will lose some mystery debug capabilities. The instructions appear to remove these capabilities from both release and debug builds, and not being a Gradle wiz, like most devs, I'm not sure how to limit this to only release builds. My guess, after some meddling, would be to put it in android { buildTypes { release, but I can't say whether that actually does the right thing.

Or maybe the Gradle snippet is usable exactly as written and meant in a "just trust us" sense? Does "DebugProbesKt.bin" get introduced only in release build dependencies? "Just trust us" is generally unwise for a dev. Please add additional explanation.

@qwwdfsad
Copy link
Collaborator

qwwdfsad commented Mar 9, 2021

but it would appear that I will lose some mystery debug capabilities.

Could you please elaborate on what exact part of debug functionality disappears when you are applying packagingOptions? The instruction tells nothing about debugging capabilities of kotlinx.coroutines and explains that "a resource file that is not required for the coroutines to operate
normally and is only used by the debugger" (meaning IDEA debugger, not application-level capabilities)

@bubenheimer
Copy link

bubenheimer commented Mar 9, 2021

The instructions given in the README say that the resource file is used by the debugger, suggesting that when I remove the resource file, the debugger will lose some functionality. This would be undesirable when debugging a debug build. I don't know what debug functionality is lost. Or is DebugProbesKt.bin just needed for some standalone debugger like jdb or Eclipse, and if I debug in IDEA or Android Studio, then I would not need the resource file?

Applying the lines from the instructions appears to remove this debugging functionality from both debug builds and release builds. Debug and release builds generally use the same Gradle build script. The instructions need to specify how to remove debugging functionality from release builds only, without also removing them from debug builds. Debug builds are specifically intended for debugging. One would want maximum debugging capabilities in this case and not lose any.

An Android Gradle Plugin expert at your organization may be able to solve this problem. @G00fY2 may know the answer, too.

@qwwdfsad
Copy link
Collaborator

qwwdfsad commented Mar 9, 2021

DebugProbesKt.bin is needed to enable the builtin support for coroutines debugger in IDEA. This functionality does not work with Android debugging at all, so no debugging capabilities are lost when packagingOptions are applied.

You don't have to worry about it and that's why we also particularly added no loss of functionality

@bubenheimer
Copy link

bubenheimer commented Mar 9, 2021

Great to know, thank you! Please add that to the README instructions to clarify why the file is safe to remove from all APKs. Something like DebugProbesKt.bin is not used when debugging on Android.

jonpryor pushed a commit to dotnet/android that referenced this issue Sep 13, 2022
Fixes: #6920

Certainly NuGet packages pull in Kotlin-related artifacts which
aren't required at runtime.  These artifacts contribute to `.apk`
package size.

The [recommendation for native Android developers][0] is to
explicitly exclude these artifacts by using `packagingOptions`:

	packagingOptions {
	  exclude 'DebugProbesKt.bin'
	}

Xamarin.Android and .NET SDK for Android developers don't use Gradle,
so the above snippet is not useful.

Add support for a new `@(AndroidPackagingOptionsExclude)` item group.
This contains a "search pattern" a'la the `searchPattern` parameter
of [`Directory.EnumerateFiles(path, searchPattern)`][1], in which:

  * `*` matches 0 or more characters
  * `?` matches 1 character.

The default items within `@(AndroidPackagingOptionsExclude)` are:

  * `DebugProbesKt.bin`
  * `*.kotlin_*`

Files which match the search patterns within
`@(AndroidPackagingOptionsExclude)` are *excluded* from `.aab` and
`.apk` files, reducing app size.

[0]: Kotlin/kotlinx.coroutines#2274
[1]: https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=net-6.0#system-io-directory-enumeratefiles(system-string-system-string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants