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 <crawshaw@golang.org>
This commit is contained in:
Elias Naur 2015-05-07 00:22:19 +02:00 committed by David Crawshaw
parent a8aa7bbd72
commit 383d14d1a3
1 changed files with 7 additions and 1 deletions

View File

@ -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 = `<manifest xmlns:android="http://schemas.android.com/apk/res/android" package=%q />`
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