Skip to content

[MIUI-Android]The widget’s Hyperlink cannot open the URL #1514

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
jiqi136 opened this issue Nov 7, 2020 · 22 comments
Closed

[MIUI-Android]The widget’s Hyperlink cannot open the URL #1514

jiqi136 opened this issue Nov 7, 2020 · 22 comments
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:Android Tickets affecting only Android devices

Comments

@jiqi136
Copy link

jiqi136 commented Nov 7, 2020

Describe the bug:

The official example generated [Android] APK can not open the URL link
https://github.com/fyne-io/fyne/tree/master/cmd/fyne_demo

I tried each of the following methods, but URL opening failed

=======

`
package main

import (
"net/url"
"log"
"os"
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)

func main() {
var giturl= "http://github.com"

log.Println("----mo一一Command , -----》")	
mo一一Command(giturl)

var Newapp = app.New()
var myWindow = Newapp.NewWindow("url") 

var git, _ = url.Parse(giturl)
_ =Newapp.OpenURL(git)

var widgeturl= widget.NewHyperlink("giturl",git)

myWindow.SetContent(widgeturl) 
myWindow.Show()
Newapp.Run() 

}

func mo一一Command(giturl string){
var cmd1 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","--user", "0","-d", giturl)
var cmd2 = exec.Command("/system/bin/am", "start", "-a", "android.intent.action.VIEW","-d", giturl)
var cmd3 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-d", giturl)
var cmd4 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-c","android.intent.category.BROWSABLE","-d", giturl)
var cmd5 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-c","android.intent.category.DEFAULT","-d", giturl)
var cmd6 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-c","android.intent.category.BROWSABLE","-d", giturl,"org.mozilla.firefox")
var cmd7 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-c","android.intent.category.DEFAULT","-d", giturl,"org.mozilla.firefox")
var cmd8 = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-d", giturl,"com.android.browser")

for _, cmd := range []*exec.Cmd{cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7,cmd8} { 
	cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
	var err=cmd.Run()
	if err != nil {
		//No error report
		log.Println("err",err) 
	}
}
return 

}`

======================
AndroidManifest.xml
File added 100 permissions

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

....
....
....

Device (please complete the following information):

  • OS:Android
  • Version: 4.4
  • Go version:1.13
  • Fyne version: 1.14
@andydotxyz
Copy link
Member

Can you please provide the errors that were encountered?
You should not need any permissions to access that function, but perhaps your version of android does not ship "am".
Can you also please provide more information about your device? There are many differences possible inside the "Android 4.4" umbrella.

@andydotxyz andydotxyz added bug Something isn't working OS:Android Tickets affecting only Android devices question A question has been asked labels Nov 9, 2020
@jiqi136
Copy link
Author

jiqi136 commented Nov 9, 2020

@andydotxyz
The tested Redmi 2 mobile phone is Android version 4.4. Because the mobile phone driver cannot be installed on the computer, adb cannot connect to the mobile phone and cannot get the record information of the error reason.

The "am" function can be used on the mobile phone, and the "am" function can be used to successfully create folders and delete files.
But the "am" command is invalid when opening files, devices or other applications. It seems to be limited to the set permissions.

To traverse, use the previous source code "am" command, which is "err== nil".

var err=cmd.Run()

if err != nil {

No error report}
`

@andydotxyz
Copy link
Member

I cannot replicate this issue, so I am asking for your help.
What is the output of your println? log.Println("err",err)

@jiqi136
Copy link
Author

jiqi136 commented Nov 9, 2020

@andydotxyz

"Am" runs without error, "err == nil".
But the "am" command is invalid when opening files, devices or other applications.

@andydotxyz
Copy link
Member

There must be some indication of it not working... if error is nil then perhaps there is some info on StdErr or StdOut?

@stuartmscott
Copy link
Member

Because the mobile phone driver cannot be installed on the computer, adb cannot connect to the mobile phone and cannot get the record information of the error reason.

This issue should be fixed first - we cannot help diagnose the error without knowing why it is breaking. Can you try with android emulator?

var git, _ = url.Parse(giturl)
_ =Newapp.OpenURL(git)

You should not ignore errors like this.

@jiqi136
Copy link
Author

jiqi136 commented Nov 9, 2020

@andydotxyz @stuartmscott
After some hard work, I finally ran ABD and saved the record file.

1.The record corresponding to "am start"
var cmd = exec.Command("am", "start", "-a", "android.intent.action.VIEW","-d", giturl)

`I/Fyne ( 9402): 26 -------mo一一Command------->

D/VoldCmdListener( 151): CommandListener runCommand mkdir argv[2]:/storage/sdcard1/Android/data/org.golang.todo.a5/files/

W/Vold ( 151): Returning OperationFailed - no handler for errno 30

D/AndroidRuntime( 9423):

D/AndroidRuntime( 9423): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<

D/AndroidRuntime( 9423): CheckJNI is OFF

E/dalvikvm( 9423): ERROR: must specify non-'.' bootclasspath

W/dalvikvm( 9423): CreateJavaVM failed: dvmClassStartup failed

E/AndroidRuntime( 9423): JNI_CreateJavaVM failed

I/Fyne ( 9402): 29 mo一一Command end <----`

2.The record corresponding to "Newapp.OpenUR"
var err=Newapp.OpenURL(git)

`I/Fyne ( 9402): 37 -------Newapp.OpenUR------->

D/AndroidRuntime( 9424):

D/AndroidRuntime( 9424): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<

D/AndroidRuntime( 9424): CheckJNI is OFF

E/dalvikvm( 9424): ERROR: must specify non-'.' bootclasspath

W/dalvikvm( 9424): CreateJavaVM failed: dvmClassStartup failed

E/AndroidRuntime( 9424): JNI_CreateJavaVM failed

I/Fyne ( 9402): 37 Newapp.OpenUR end <--- `

3."widget.NewHyperlink"对应的记录
var widgeturl= widget.NewHyperlink("giturl",git)

查看上传的附件

test.log

@stuartmscott
Copy link
Member

This is progress, now we know the actual issue is:

E/dalvikvm( 9424): ERROR: must specify non-'.' bootclasspath

Is this using a physical device or the android emulator?

@jiqi136
Copy link
Author

jiqi136 commented Nov 9, 2020

@stuartmscott
Real Android phone operation and finger click operation

@stuartmscott
Copy link
Member

Try with the emulator so we know whether it is an issue with your device or not

@jiqi136
Copy link
Author

jiqi136 commented Nov 12, 2020

@stuartmscott

I tried the latest mobile phones of three brands, and they all worked and opened the website.

VMware virtual machine is equipped with Android-x86-5.1-rc1.iso, although it crashed in the end,
But the URL was successfully opened before the crash.(var err=Newapp.OpenURL(git))

@andydotxyz
Copy link
Member

What is special about this device I wonder? What is the manufacturer/model and are there any operator-customisations loaded?

@jiqi136
Copy link
Author

jiqi136 commented Nov 13, 2020

@andydotxyz

Mobile phone name: Hongmi mobile phone
Mobile phone model: HM2a
Android version: 4.4.4KTU84Q
MIUI version: MIUI9.2

@andydotxyz
Copy link
Member

Ah, so the MIUI is not really Android I think.
The classpath configuration may be incompatible with certain standard actions - and it looks like "am" is one of those things that does not work.
I guess we need to see if there is an Android API that MIUI still supports that we can use instead

@andydotxyz andydotxyz changed the title [Android]The widget’s Hyperlink cannot open the URL [MIUI-Android]The widget’s Hyperlink cannot open the URL Nov 14, 2020
@donatj
Copy link
Contributor

donatj commented Dec 14, 2020

For what it's worth I am having the same problem on my Google Pixel 4a XL

@donatj
Copy link
Contributor

donatj commented Dec 14, 2020

url, _ := url.Parse("https://www.google.com")
err := fyne.CurrentApp().OpenURL(url)
fmt.Println(err);

gets me

exit status 255

@andydotxyz
Copy link
Member

That is very helpful thank you @donatj.

Is it possible for you find the appropriate entry in your android log?
Before the 255 exit there should be output printed. This content will be in the Android log (adb logcat) with a Fyne or Go prefix...

@stuartmscott
Copy link
Member

stuartmscott commented Feb 19, 2021

I just hit this too on Pixel 2 w/ Android 11 (though not using a widget.Hyperlink, instead using a widget.Button that calls app.App.OpenURL, but I think the widget is irrelevant to this bug);

02-19 08:00:42.814 15898 15935 I Fyne    : Starting: Intent { act=android.intent.action.VIEW dat=https://space-nyc.aletheiaware.com/... }
--------- beginning of system
02-19 08:00:42.815  1427  2064 W ActivityTaskManager: Permission Denial: package=com.android.shell does not belong to uid=10298
02-19 08:00:42.815 15898 15931 E Fyne    : 
02-19 08:00:42.815 15898 15931 E Fyne    : Exception occurred while executing 'start':
02-19 08:00:42.815 15898 15931 E Fyne    : java.lang.SecurityException: Permission Denial: package=com.android.shell does not belong to uid=10298
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.assertPackageMatchesCallingUid(ActivityTaskManagerService.java:2598)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1081)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1072)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3678)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:544)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:186)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.ShellCommand.exec(ShellCommand.java:44)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10522)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.Binder.shellCommand(Binder.java:929)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.Binder.onTransact(Binder.java:813)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5027)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2883)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.Binder.execTransactInternal(Binder.java:1159)
02-19 08:00:42.815 15898 15931 E Fyne    : 	at android.os.Binder.execTransact(Binder.java:1123)
02-19 08:00:42.815 22360 22362 I cmd     : oneway function results will be dropped but finished with status OK and parcel size 4
02-19 08:00:42.817 15898 15930 I Fyne    : 2021/02/19 08:00:42 fyne.go:491: Error: exit status 255

@AlbinoGeek
Copy link
Contributor

AlbinoGeek commented Feb 19, 2021

I just hit this too on Pixel 2 w/ Android 11

Nevermind, android:exported="true" is for an application to indicate that IT can be launched by others.

Sorry for the false positive.

@donatj
Copy link
Contributor

donatj commented Feb 19, 2021

Finally figured out how to use logcat (sorry, I'm not primarily an Android dev)

02-19 11:13:59.703 13176 13237 I Fyne    : Starting: Intent { act=android.intent.action.VIEW dat=https://github.com/... }
02-19 11:13:59.703 13176 13237 E Fyne    : 
02-19 11:13:59.703 13176 13237 E Fyne    : Exception occurred while executing 'start':
02-19 11:13:59.703 13176 13237 E Fyne    : java.lang.SecurityException: Permission Denial: package=com.android.shell does not belong to uid=10373
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.assertPackageMatchesCallingUid(ActivityTaskManagerService.java:2594)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1077)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1068)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:3662)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:544)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:186)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at android.os.ShellCommand.exec(ShellCommand.java:44)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10505)
02-19 11:13:59.703 13176 13237 E Fyne    : 	at android.os.Binder.shellCommand(Binder.java:929)
02-19 11:13:59.704 13176 13237 E Fyne    : 	at android.os.Binder.onTransact(Binder.java:813)
02-19 11:13:59.704 13176 13237 E Fyne    : 	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5053)
02-19 11:13:59.704 13176 13237 E Fyne    : 	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2867)
02-19 11:13:59.704 13176 13237 E Fyne    : 	at android.os.Binder.execTransactInternal(Binder.java:1159)
02-19 11:13:59.704 13176 13237 E Fyne    : 	at android.os.Binder.execTransact(Binder.java:1123)
02-19 11:13:59.704 14282 14284 I cmd     : oneway function results will be dropped but finished with status OK and parcel size 4
02-19 11:13:59.707 13176 13266 I Fyne    : Fyne error:  Failed to open url
02-19 11:13:59.707 13176 13266 I Fyne    :   Cause: exit status 255
02-19 11:13:59.707 13176 13266 I Fyne    :   At: /Users/jdonat/gocode/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/hyperlink.go:115

@andydotxyz
Copy link
Member

Would it be possible to run a simple app on one of these devices to launch it using the activity API like this:
https://stackoverflow.com/questions/2201917/how-can-i-open-a-url-in-androids-web-browser-from-my-application

That might help track down if it is solvable by removing dependency on the helper tool we invoke.

@andydotxyz andydotxyz added blocker Items that would block a forthcoming release and removed question A question has been asked labels Sep 10, 2021
@andydotxyz
Copy link
Member

Resolved on develop branch for v2.1, apologies for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:Android Tickets affecting only Android devices
Projects
None yet
Development

No branches or pull requests

5 participants