Search Unity

Extra Permission needed in Android ?

Discussion in 'Unity Analytics' started by circusfishcom, Feb 3, 2015.

  1. circusfishcom

    circusfishcom

    Joined:
    Jan 13, 2015
    Posts:
    1
    Is there extra permission needed when publish android ?
    e.g.
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    In Unity Editor all the scripts works fine, but not work as apk
     
    yoyo696 likes this.
  2. PAHeartBeat

    PAHeartBeat

    Joined:
    Jul 11, 2012
    Posts:
    76
    Hi Circusfishcom,

    I thought you need it,
    Internet persmmison need to post analytics information to Unity Cloud server, but i thouthg if tou not have create any manifest in folder Plugins/Android then Unity may create a fresh manifest from Build Player settings. so if you don't have any manifest in Plugins/Android folder please check you have selected Internet access as required in Andorid Player Settings for build.

    I thouht Unity Analytics need that permssion to identify is device connetected to internet or not, As I have communticatin with unity via blog, unity cache analytics events if internet connection not present and sent it to unity cloud when internet connection available.

    So As My view that both permission are required.
     
    momentaRobin likes this.
  3. sschan

    sschan

    Moderator

    Joined:
    Oct 8, 2014
    Posts:
    87
    Hi @circusfishcom,

    We are looking into your question and will get back to you shortly with a response. Thanks!
     
  4. kentunity

    kentunity

    Unity Technologies

    Joined:
    Sep 16, 2014
    Posts:
    55
    @PAHeartBeat is correct, both permissions are needed by our SDK,
    however, those two permissions should be added automatically during the build process to the generated build's AndroidManifest.xml.

    Could you do a Google Android Project Build by going to "Build Settings"> click Android > check Google Android Project > Export.
    Then on the generated Google Android Project's AndroidManifest.xml, it should have these two entries
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    Can you also share the Unity Version and Analytics SDK version you are using?
     
  5. jejeblue

    jejeblue

    Joined:
    Nov 4, 2014
    Posts:
    2
    I have a same problem.

    I made aphace-mysql-php server and call php file by WWW webReq = new WWW in unity C#.
    It works well in unity editor, but not in an android phone apk. And except this, all other features work well.

    I tested php file call in an android phone's web brower, and worked well.
    Only unity app in an android phone does not work.

    I exported google android project, and checked <AndroidManifest.xml>.

    It had a first line(<uses-permission android:name="android.permission.INTERNET"/>), and second line(<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>) is not exist in it.

    My unity version is <5.0.0f4 Personal>.
     
    Last edited: Mar 17, 2015
  6. kentunity

    kentunity

    Unity Technologies

    Joined:
    Sep 16, 2014
    Posts:
    55
    Simply doing a WWW will only add INTERNET permission. Our SDK does network connection checks that requires ACCESS_NETWORK_STATE permission.

    Since your problem isn't related to Analytics, but I would be glad to help you in private. Please check your inbox.
     
  7. lrasomattos

    lrasomattos

    Joined:
    Aug 22, 2015
    Posts:
    29
    Hi! It looks like I got the same problem. I'm using Unity 5.4 .0b10

    After linking the service for Analytics, the game crashes on launch on Android device (works well on Editor).
    I thought it could be a problem in the SDK since unity was complaining when building: "SDK Build Tools 22 < 23". But after upgrading the problem continued.

    adb shows an error:
    Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)

    The manifest doesn't have any added permissions for networking:
    <application android:theme="@StyLe/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@String/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner">
    <activity android:label="@String/app_name" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:name="com.longhathouse.dandara.UnityPlayerActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    </intent-filter>
    <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    </application>
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23" />
    <uses-feature android:glEsVersion="0x00020000" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />

    Also, now that I noticed the touchscreen requirements, how can I change them through the inspector. the game actually requires multitouch.
     
  8. lrasomattos

    lrasomattos

    Joined:
    Aug 22, 2015
    Posts:
    29
    I managed to add the INTERNET permission to the manifest through player settings by setting Internet Access to Required.
    Now the game runs without crashing, but the game's data from the Android device is still not appearing on Analytic's Validate

    - Update -

    Despite being reluctant to add my own manifest.xml (I don't like messing it up when unity will add automatic/playerSettings stuff over it). I created the file and tried to put in a minimal manifest info:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
    android:label="@String/app_name">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    </manifest>


    Now the resulting manifest has the permissions. But still, Android data doesn't go to Unity Analytics. Am I missing something?

    - Update 2 -

    Even with this solution the game crashes on a friend's phone (android 4.4).
    Also in another device it worked and the Events were appearing on Analytic's Validate. In the end it looks like making it work is a matter of luck.
     
    Last edited: Apr 6, 2016
  9. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    Hi @lrasomattos,

    It's possible the data not appearing in the validator is a different issue....you mentioned the analytics SDK, are you upgrading from the sdk version (editor versions older than 5.2)? If so, you have to make sure all of the old SDK files are deleted from the project's folders. Our manual has some tips for upgrading (http://docs.unity3d.com/Manual/UnityAnalyticsUpgrading.html)

    If that's not the case, there still might be some other reasons...Can you fill out a support ticket with your appid and the specifics of how you have integrated Analytics so far so I can look more into your specific case? Thanks! Here's the link: https://analytics.cloud.unity3d.com/support
     
  10. lrasomattos

    lrasomattos

    Joined:
    Aug 22, 2015
    Posts:
    29
    Hi @erika_d! Thanks,

    I mentioned the Android SDK, not Analytics'. But I think in the end the manifest kinda solved the problem.

    What created the confusion is that the game started crashing in a friend's phone, but when we used adb to log the error, it doesn't seem connected to Analytics like the other crashes (that complained about Internet permission).. It probably originated after we upgraded from Unity 5.3 to 5.4beta.

    About the data not appearing, it was because we didn't know only Development Builds' data would appear in the Validator. (My bad!)


    Still, I hate messing with the AndroidManifest.xml. I fear we could be overriding something important that unity or other plugins would add. (For example, the manifest above will messes up with the Icons, and I had to add <application android:icon="@drawable/app_icon"> manually for it to work).

    Also we just recreated the project in 5.4beta, only pasting the assets, in case some old config was causing our friend's crash. And even in the new project the Internet permissions won't be added automatically.

    If you have a minimal impact example of manifest I could use, or a solution for it to be automatic (like it should be already happening) let me know!
     
  11. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    Hi @lrasomattos,

    I'm glad you were able to figure out the issues with the Validator and the crashes...I don't think you should have to be editing the manifest file though, so I'm going to try and duplicate your issue and get back to you!
     
    lrasomattos likes this.
  12. TGruenwald

    TGruenwald

    Joined:
    Dec 18, 2012
    Posts:
    1
    I've also had trouble with some Android devices successfully posting data to Unity Analytics while others do not. Any advice on how to troubleshoot that?
     
  13. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    Hi @TGruenwald,

    Are these devices all test devices? If so have you tried doing a development build on them and checking to see whether the events show up in the validator? What indicators are making you think some are successfully posting and some aren't? (i.e. are you looking at the Android segment and seeing different numbers then your expectations? Or is your DAU lower than expected?)
     
  14. erika_d

    erika_d

    Joined:
    Jan 20, 2016
    Posts:
    413
    Hi @lrasomattos,

    Sorry for the delay in responding to this! After doing some testing and research, I was not able to duplicate the issue you had with the internet permission not being added to your manifest. It seemed to add to mine whether or not I selected Auto or Required on the Internet Access setting in the Player Settings. (I was using 5.4.0b4). I would say that changing it to Required as you did would be the best way to force it to show up there in cases when it doesn't for whatever reason.

    On the multitouch stuff: It looks like there is not a way in the editor to change required to true. When required is false, what it's saying is that it can use multitouch if the device has it, and if the device doesn't have it, it won't break the app. True is saying, do not let any device without multitouch download the app as it will break it.

    Based on my research, it looks like Unity will merge multiple manifest files, so if you create a manifest file that sets the multitouch required to true, and other plugins have their own manifest files, they should get merged. I was able to get it to work by creating a manifest file in this path Assets/Android/AndroidManifest.xml. Then I copied over the application part of the original file (although that might not be entirely necessary) and then only adding the two multitouch uses-feature lines. The other lines (like Internet Permission and the other uses-features) were appended to the end of my file.

    I hope that despite the delay, the information is helpful!
     
    mpinol likes this.
  15. dobrMAN

    dobrMAN

    Joined:
    Mar 18, 2015
    Posts:
    8
    Hi!
    I have another problem, but very similar.
    I use the internet in my project, and when I create an apk on my computer, it works fine (requires internet access), but if I collect APK in the "Cloud BUILD", it is collected without permission for Internet access, and my application does not work .
    How to fix it?
     
  16. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519