From 383d14d1a39be500c8d8327d0fb2b25f0443d72f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 7 May 2015 00:22:19 +0200 Subject: [PATCH] mobile/cmd/gomobile: add proguard.txt to gomobile bind .aar files The gomobile bind command outputs an .aar file ready to include in an Android project. If the including project use the minifyEnabled gradle option the field go.Seq.memptr will be removed since it is only referenced from C code. Instruct the minifier to keep all go.* java code by adding an appropriate proguard.txt file to the .aar file. Change-Id: Ia1e89a5d8f4b4f349f9c2cf4d0dba2628557fdf9 Reviewed-on: https://go-review.googlesource.com/9802 Reviewed-by: David Crawshaw --- cmd/gomobile/bind.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/gomobile/bind.go b/cmd/gomobile/bind.go index 8804e38..0a2a9a4 100644 --- a/cmd/gomobile/bind.go +++ b/cmd/gomobile/bind.go @@ -311,7 +311,7 @@ func main() { // R.txt (mandatory) // res/ (mandatory) // libs/*.jar (optional, not relevant) -// proguard.txt (optional, not relevant) +// proguard.txt (optional) // lint.jar (optional, not relevant) // aidl (optional, not relevant) // @@ -345,6 +345,12 @@ func buildAAR(androidDir string, pkg *build.Package) (err error) { const manifestFmt = `` fmt.Fprintf(w, manifestFmt, "go."+pkg.Name+".gojni") + w, err = aarwcreate("proguard.txt") + if err != nil { + return err + } + fmt.Fprintln(w, `-keep class go.** { *; }`) + w, err = aarwcreate("classes.jar") if err != nil { return err