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

Internet on Android needs android.permission.INTERNET - how to add? #1715

Closed
joonas-fi opened this issue Jan 4, 2021 · 5 comments
Closed
Labels
question A question has been asked

Comments

@joonas-fi
Copy link
Contributor

I couldn't use the network from my app, which I found to be surprising. I decompiled the .apk to check AndroidManifest.xml to find out it's missing the INTERNET permission.

It seems like there isn't a way to add extra permissions from command line, since the permissions are hardcoded:

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

Am I expected to supply custom manifest file? I couldn't find from documentation a mention of how to do it.

My workaround was (I'm using fyne-cross):

  • Fork fyne
  • Patch the hardcoded manifest to include the permission, re-compile $ fyne
  • Derive a new Docker image for fyne-cross by replacing the fyne binary with my custom one
  • Use $ fyne-cross android -image=MY_CUSTOM_IMAGE

The patch was (NOTE: it's missing the also-recommended ACCESS_NETWORK_STATE):

diff --git a/cmd/fyne/internal/mobile/manifest.go b/cmd/fyne/internal/mobile/manifest.go
index 96884fd1..29b6a2f5 100644
--- a/cmd/fyne/internal/mobile/manifest.go
+++ b/cmd/fyne/internal/mobile/manifest.go
@@ -78,4 +78,5 @@ var manifestTmpl = template.Must(template.New("manifest").Parse(`
 
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+       <uses-permission android:name="android.permission.INTERNET" />
 </manifest>`))
@andydotxyz
Copy link
Member

If your app has an AndroidManifest.xml then the compiler will use that instead.

@andydotxyz andydotxyz added the question A question has been asked label Jan 4, 2021
@joonas-fi
Copy link
Contributor Author

Great to hear that there is a solution!

I couldn't find this behaviour from the documentation, it would be helpful for newcomers like me if this is mentioned somewhere accessible.

Would you like me to send a PR to developer.fyne.io repo? Perhaps this page, my rough proposal:

  • New heading, "Platform-specific considerations, Android"?
  • Text: "Network inaccessible by default, you have to supply custom AndroidManifest.xml", with link to this issue (your answer specifically) so we don't have to write as much text in the documentation?

@AlbinoGeek
Copy link
Contributor

@joonas-fi I think this should be documented, yes--as inevitably I was going to ask this question 👍🏻

@andydotxyz
Copy link
Member

I've updated for internet on by default from 2.0.2.
The metadata work we're doing for 2.1 can have the option to turn this off #1431.

andydotxyz added a commit that referenced this issue Mar 18, 2021
Our upcoming metadata file can turn this off if we need to.
Fixes #1715
@andydotxyz
Copy link
Member

Resolved on develop and will be added to next release.

andydotxyz added a commit that referenced this issue Mar 22, 2021
Our upcoming metadata file can turn this off if we need to.
Fixes #1715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question has been asked
Projects
None yet
Development

No branches or pull requests

3 participants