aboutsummaryrefslogtreecommitdiffstats
path: root/mobile
diff options
context:
space:
mode:
Diffstat (limited to 'mobile')
-rw-r--r--mobile/android_test.go15
-rw-r--r--mobile/bind.go20
2 files changed, 24 insertions, 11 deletions
diff --git a/mobile/android_test.go b/mobile/android_test.go
index 345e009b4..3d3bd66d0 100644
--- a/mobile/android_test.go
+++ b/mobile/android_test.go
@@ -72,7 +72,7 @@ public class AndroidTest extends InstrumentationTestCase {
Transaction tx = new Transaction(
1, new Address("0x0000000000000000000000000000000000000000"),
- new BigInt(0), new BigInt(0), new BigInt(1), null); // Random empty transaction
+ new BigInt(0), 0, new BigInt(1), null); // Random empty transaction
BigInt chain = new BigInt(1); // Chain identifier of the main net
// Sign a transaction with a single authorization
@@ -164,12 +164,17 @@ func TestAndroid(t *testing.T) {
t.Skip("command gradle not found, skipping")
}
if sdk := os.Getenv("ANDROID_HOME"); sdk == "" {
- t.Skip("ANDROID_HOME environment var not set, skipping")
+ // Android SDK not explicitly given, try to auto-resolve
+ autopath := filepath.Join(os.Getenv("HOME"), "Android", "Sdk")
+ if _, err := os.Stat(autopath); err != nil {
+ t.Skip("ANDROID_HOME environment var not set, skipping")
+ }
+ os.Setenv("ANDROID_HOME", autopath)
}
if _, err := exec.Command("which", "gomobile").CombinedOutput(); err != nil {
t.Log("gomobile missing, installing it...")
- if _, err := exec.Command("go", "install", "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
- t.Fatalf("install failed: %v", err)
+ if out, err := exec.Command("go", "get", "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
+ t.Fatalf("install failed: %v\n%s", err, string(out))
}
t.Log("initializing gomobile...")
start := time.Now()
@@ -239,7 +244,7 @@ const gradleConfig = `buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
diff --git a/mobile/bind.go b/mobile/bind.go
index 1e861d0bc..d6e621a25 100644
--- a/mobile/bind.go
+++ b/mobile/bind.go
@@ -138,7 +138,7 @@ func BindContract(address *Address, abiJSON string, client *EthereumClient) (con
return nil, err
}
return &BoundContract{
- contract: bind.NewBoundContract(address.address, parsed, client.client, client.client),
+ contract: bind.NewBoundContract(address.address, parsed, client.client, client.client, client.client),
address: address.address,
}, nil
}
@@ -154,12 +154,20 @@ func (c *BoundContract) GetDeployer() *Transaction {
// Call invokes the (constant) contract method with params as input values and
// sets the output to result.
func (c *BoundContract) Call(opts *CallOpts, out *Interfaces, method string, args *Interfaces) error {
- results := make([]interface{}, len(out.objects))
- copy(results, out.objects)
- if err := c.contract.Call(&opts.opts, &results, method, args.objects...); err != nil {
- return err
+ if len(out.objects) == 1 {
+ result := out.objects[0]
+ if err := c.contract.Call(&opts.opts, result, method, args.objects...); err != nil {
+ return err
+ }
+ out.objects[0] = result
+ } else {
+ results := make([]interface{}, len(out.objects))
+ copy(results, out.objects)
+ if err := c.contract.Call(&opts.opts, &results, method, args.objects...); err != nil {
+ return err
+ }
+ copy(out.objects, results)
}
- copy(out.objects, results)
return nil
}