Skip to content
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

x/mobile/cmd/gomobile: INSTALL_FAILED_INVALID_APK when dashes in package #12273

Open
mokiat opened this issue Aug 22, 2015 · 11 comments
Open

x/mobile/cmd/gomobile: INSTALL_FAILED_INVALID_APK when dashes in package #12273

mokiat opened this issue Aug 22, 2015 · 11 comments
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@mokiat
Copy link

mokiat commented Aug 22, 2015

Hi,

It seems that it is not possible to build an Android application from Go source code if there is a dash (-) somewhere in the Go package name. Since my organization on GitHub has a dash inside, this means I cannot build any Android applications whatsoever.

You can easily test this with the currently available Go 1.5 release version.

  1. Take the golang.org/x/mobile/example/basic example application and move it to the golang.org/x/mobile/example/basic-demo folder.
  2. Run gomobile build -target=android golang.org/x/mobile/example/basic-demo command.
  3. Run the adb install basic-demo command.

You will get the following error:

6927 KB/s (3293500 bytes in 0.464s)
    pkg: /data/local/tmp/basic-demo.apk
Failure [INSTALL_FAILED_INVALID_APK]

Now, you might ask me why didn't I use the gomobile install command instead. There seems to be another issue as well. If you run the gomobile install command, you will not receive any output to the terminal at all. Furthermore, you will even get an exit code of 0. It seems that the gomobile command hides any issues coming from the adb command.

My best guess is that somewhere in the manifest you place the package name. At least for Java based applications, I know that they don't allow dashes in the package names and you are advised to substitute those with underscores. (http://stackoverflow.com/questions/3179216/what-is-the-convention-for-word-separator-in-java-package-names) I guess a similar validation is performed even if the application is not Java based. This is just a hunch, I might be totally off base.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Aug 22, 2015
@ianlancetaylor
Copy link
Contributor

CC @crawshaw

@crawshaw crawshaw self-assigned this Aug 24, 2015
@gopherbot
Copy link

CL https://golang.org/cl/13873 mentions this issue.

crawshaw added a commit to golang/mobile that referenced this issue Aug 24, 2015
Updates golang/go#12273

Change-Id: I8eac3e84d5a473e9ffe45705cea88537573aef61
Reviewed-on: https://go-review.googlesource.com/13873
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@sebaslogen
Copy link

I have the new project without dash on a Windows machine and I get exactly the same problem.
Compiling goes well but the APK produced is invalid.

C:\software\go\src\golang.org\x\mobile\example\basic
> gomobile install -target android golang.org\x\mobile\example\basic
3008 KB/s (3450146 bytes in 1.120s)
    pkg: /data/local/tmp/basic.apk
Failure [INSTALL_FAILED_INVALID_APK]

@stmuk
Copy link
Contributor

stmuk commented Nov 12, 2015

Confirmed this issue exists on OS X as well and I just lost an hour to it!

@hyangah
Copy link
Contributor

hyangah commented Nov 12, 2015

Please provide the output of

% go version
% gomobile version

and device model & android version.

Also,

@neoranga55 Can you send me the produced basic.apk?
@stmuk Does your app have dash in the package name? Or do you have a problem with the basic example as well?

@stmuk
Copy link
Contributor

stmuk commented Nov 12, 2015

% go version
go version go1.5.1 darwin/amd64

% gomobile version
gomobile version +a54776c Wed Nov 11 22:33:35 2015 +0000 (android,ios); androidSDK=

The issue I saw was installing from a directory with a dash in it "go-mobile" the app itself didn't contain a dash and neither did it use a package with one. The target platform was HTC One M7 with Android 5.0.2

Renaming the directory fixed the problem and I was able to run on Android and IOS

@stmuk
Copy link
Contributor

stmuk commented Nov 12, 2015

To clarify I had no problems with any example apps.

@sebaslogen
Copy link

go version
go version go1.5.1 windows/amd64

gomobile version
gomobile version +83be1bf Thu Oct 8 21:24:20 2015 +0000 (android); androidSDK=C:\Users\MyUser\AppData\Local\Android\sdk\platforms\android-23

On a Xperia Z3 with 5.1.1

APK is in the link and MD5 sum is 0ACE1CC04AB31127C43424E01D18EC51
http://s000.tinyupload.com/index.php?file_id=90941633308815548327

@gopherbot
Copy link

CL https://golang.org/cl/16875 mentions this issue.

hyangah added a commit to golang/mobile that referenced this issue Nov 18, 2015
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

"This can occur if the domain name contains a hyphen or other special
character, if the package name begins with a digit or other character
that is illegal to use as the beginning of a Java name, or if the
package name contains a reserved Java keyword, such as "int". In this
event, the suggested convention is to add an underscore."

The sanitized name is used for the app package name and the default apk
file name.

Update golang/go#12273

Change-Id: I76d7f423e87c54a5bb7ab71ec251fd3a26da9722
Reviewed-on: https://go-review.googlesource.com/16875
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@eliasnaur
Copy link
Contributor

Is this still a problem?

@mokiat
Copy link
Author

mokiat commented Mar 17, 2018

@eliasnaur , no idea. I moved away from gomobile a few years ago due to many instabilities in the package at the time. It is good to see that effort is still ongoing and I expect things have changed now.

Maybe other people in the thread that have also experienced the issue can check.

imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Updates golang/go#12273

Change-Id: I8eac3e84d5a473e9ffe45705cea88537573aef61
Reviewed-on: https://go-review.googlesource.com/13873
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

"This can occur if the domain name contains a hyphen or other special
character, if the package name begins with a digit or other character
that is illegal to use as the beginning of a Java name, or if the
package name contains a reserved Java keyword, such as "int". In this
event, the suggested convention is to add an underscore."

The sanitized name is used for the app package name and the default apk
file name.

Update golang/go#12273

Change-Id: I76d7f423e87c54a5bb7ab71ec251fd3a26da9722
Reviewed-on: https://go-review.googlesource.com/16875
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Updates golang/go#12273

Change-Id: I8eac3e84d5a473e9ffe45705cea88537573aef61
Reviewed-on: https://go-review.googlesource.com/13873
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

"This can occur if the domain name contains a hyphen or other special
character, if the package name begins with a digit or other character
that is illegal to use as the beginning of a Java name, or if the
package name contains a reserved Java keyword, such as "int". In this
event, the suggested convention is to add an underscore."

The sanitized name is used for the app package name and the default apk
file name.

Update golang/go#12273

Change-Id: I76d7f423e87c54a5bb7ab71ec251fd3a26da9722
Reviewed-on: https://go-review.googlesource.com/16875
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

8 participants