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

Few questions about this plugin #4

Closed
megasoft78 opened this issue May 24, 2018 · 19 comments

Comments

@megasoft78
Copy link

commented May 24, 2018

Hi,
I'm following this repository because I'm interested into convert my existing Unity game into an Instant Game.
I have 2 main questions:

  1. I remember the same plugin was published the same day it was announced on Google I/O and after few hours it was removed. Is this the same plugin or a new one? It seems you are writing it from scratch.
  2. How is possible to keep the apk size under 10MB if an empty project in Unity 2017 is already over 10MB? I tried using Mono and it's over 10MB and I tried with IL2CPP and it's 7MB but as soon as you add any code it grow very quickly to over 10MB? What am I doing wrong?

Best Regards

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented May 24, 2018

Hello, thank you for your interest and for reaching out.

  1. This is the same plugin, but with additional features and bug fixes. We needed to take the plug-in down temporarily while we fixed some critical bugs. We just released the beta today, so please check the releases page for a .unitypackage that you can import into your project.

  2. Keeping the size of a Unity APK below 10MB is a challenge that we are actively working on. In the short term you're right that using IL2CPP with engine stripping is the best approach for staying below the limit. Another technique to explore is the use of remote AssetBundles. See creating assetbundles and downloading assetbundles. We'll post a guide here on how to do this as soon as it is ready. Over the next few months we are also working on strategies with Unity to reduce APK size. In the meantime, you can also sign up for the Unity Beta Program to get access to new beta features and the latest news.

Thanks!

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 25, 2018

Hi,
thank you for your answers.
I already tried the plugin but I'm having a problem to run it:
image
image

I'm using Unity 2017.4.2f2 on Windows 10 and an empty project to test it.

About the Unity Beta Program, I already subscribe during Google I/O but I didn't received any email.
I'm already testing Unity 2018.2.0b4 and I don't see anything new that can help me to reduce apk size. Is this program allow me to access to hidden features?

I'm trying to compare an empty project with my game using Android Studio Analyze Apk:
image
image

Now I can try to optimize my assets and maybe use proguard to reduce classes.dex but unless Unity engine leave 2-3MB available I don't see how I can keep the entire apk below 10MB.
Do you know if it's possible to identify which part of my game code is taking most of the space?
My game is quite small and I don't have massive code in there.

Thank you in advance. :)

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 25, 2018

Hi,
I was able to run my game using the plugin.
It seems the plugin didn't update properly my AndroidManifest.xml.
I added this and it's working now:

      <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />

        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:host="instant.apps" />
        <data android:pathPrefix="/it.megasoft78.wordsjungle" />
      </intent-filter>

      <meta-data
          android:name="default-url"
          android:value="https://instant.apps/it.megasoft78.wordsjungle" />

I have another small issue. I'm using Google Admob Consent SDK but when I run I'm getting this:
onFailedToUpdateConsentInfo : Cleartext HTTP traffic to adservice.google.com not permitted

I need that Consent dialog to be GDPR complaint. Any idea if this can be fixed?

I'm still investigating on a way to reduce apk size below 10MB. At the moment it's about 14MB. I tried with Mono and IL2CPP and it seems for my game the final apk size is about the same.
I imagine that stripping is not working for a full project as I may use Unity features that increase apk size.
My problem is that without any assets and classes.dex the apk size is already 10MB:
image

Could you please help me?

Thank you in advance. :)

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented May 25, 2018

Hi again, thank you for trying the plugin!

Regarding the "adb install failed for file devman.apk":

  • Did that issue resolve itself just by running the command again, or did you do something specific to fix it?

Regarding "It seems the plugin didn't update properly my AndroidManifest.xml":

  • If I understand correctly you filled in a value for "Instant Apps URL (Optional)" but when you clicked "Save" you got an error?
  • Were there any errors in the Unity console?
  • Does your manifest contain multiple activities and/or multiple view intents on the main activity?
  • I'd love to fix any issues here so that you don't have to copy the view intent manually!

Regarding Google Admob Consent SDK:

Regarding app size:

  • I don't have too much additional to add beyond what I shared yesterday on current strategies and the fact that we're actively working on improving this situation, but let me try
  • I notice that your classes.dex is 1.7MB which is pretty large.
    • Are you using many additional aar or jar files? Are any of them not needed for your instant app such that they can be removed from the project?
    • Can you try enabling proguard either through the Unity editor or in the build.gradle file that Unity generates?
  • For the IL2CPP build I see a 5.2MB libunity.so, which must mean that you already have engine stripping enabled
  • If you want to see what engine components are being retained (and conversely know what is being stripped) you can look in the build output file Temp/StagingArea/strip/armeabi-v7a/UnityClassRegistration.cpp (there may be easier places to see this)
    • Sometimes developers are surprised to learn that their 2D game is retaining a 3D physics component, e.g. because it's pulled in as a dependency of TextMesh Pro
@megasoft78

This comment has been minimized.

Copy link
Author

commented May 25, 2018

Hi,
about devman.apk it seems to be a specific issue with MI 5 device and MIUI OS.
I tried on my Nexus 7 2013 and it's working fine.
About AndroidManifest.xml not properly update, I mean that it regenerate it but without add the intent-filter. I didn't provide the url on that dialog as it was optional and it didn't show me any errors or warnings. I tried with an empty project and I get the same result. I make it work by manually adding the intent-filter in my AndroidManifest.xml.
About Consent SDK they resolve it because I raise an issue on the github repository. :)
Here's my current progress about reducing apk size:
image

I'm really close to 10MB but I had to remove : Google Play Games, Admob and Unity Analytics and IAP.
I also optimized my textures:
image

I'll try out your suggestion about UnityClassRegistration.cpp.
Is it possible to control compiler/linker flags to maybe try to optimize them?

As far as you know are Unity and Google working on a new version of Unity to make apk size smaller?
I recently see a talk about Unity making the core engine for messaging game (javascript) in 76kb. Are they working on a similar thing for Android?

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 25, 2018

Hi again,
I attached my UnityClassRegistration.cpp.
It seems to include Physics but I'm not using it. Is it possible to remove it? How?
Can you see anything I can remove in that file?

UnityClassRegistration.zip

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented May 25, 2018

Wow, that's great that you've already made it from 14.6MB down to 10.2MB in less than a day!

It seems to include Physics but I'm not using it. Is it possible to remove it? How?
Can you see anything I can remove in that file?

I haven't tried this yet, but it may be possible to understand why a component has been retained by checking the Build Report's StrippingInfo in 2018.1. I'm not sure if you can (at least temporarily) import your project into 2018.1 or not, but if so, that may provide some clues.

About AndroidManifest.xml not properly update, I mean that it regenerate it but without add the intent-filter. I didn't provide the url on that dialog as it was optional and it didn't show me any errors or warnings.

I see, perhaps I haven't done a good job of explaining the choices in that UI:

  • One option is to create a "URL-less" instant app where you don't need to specify a URL and do domain verification. In this case we create an Instant app URL for you. This is why that box is marked "(Optional)".
  • The other option is to define a URL in the manifest, which is supposed to be automated by the plugin if you enter a URL in that text box.

Was it unclear what your choices were with the URL? I can try to make the UI clearer.

Are you able to try it now, and does it work or give an error?

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 26, 2018

Hi,
thank you for the suggestion about Build Report tool. I'll try it now.
About the option I think it was explained well. What I did is use the URL-less option and click save but it didnt' add the intent-filter to my AndroidManifest.xml.
I attached a small video about it. :)
tes.zip

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 26, 2018

Hi,
I'm still working to optimize apk size. I'd like to keep In-App and Admob in my instant game but at the moment with that is 12mb :(
I have 3 additional questions about this plugin:

  1. Is this plugin going to support the possibility to detect is it's an Instant app and to show the Install prompt like in this link? https://developer.android.com/topic/google-play-instant/reference#showinstallprompt
  2. Do I need to do anything special to keep the users data between Instant Game and Installed one? I'm using PlayerPrefs.
  3. I'm trying to share a screenshot when the user ask for that. It's working on the installed version but not in the Instant Game. I'm using file provider for that. It looks like the file is not accessible. Do I need to ask for permission at runtime? How?

Thank you. :)

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 28, 2018

Hi,
I finally publish my instant game.
My Instant Game is a limited version without Ads and In-App and only first 25 levels. It's about 9MB.
I removed the possibility to share screenshot and I was able to implement the showInstallPrompt.

A small note is about the library iTween I was using. I replace it with a different one because when I build it was taking about 1.5MB additional. Probably by including physics that I don't use.

Another issue I had is about using url https://instant.apps/it.megasoft78.wordsjungle.
When I try to upload using that url, Google Developer Console give me an error about verification.
I used my own server to validate the url but it would be handy if we can use that url instead. :)

About the transfer of the data (Game state) between the Instant Game and the Installed one I implemented using the post install intent in the showInstallPrompt but it doesn't seem to work.

I tested the installed one using adb and it's working for sure. I'm using the following command:
adb shell am start -n it.megasoft78.wordsjungle/com.unity3d.player.UnityPlayerActivity --es "data" "MyEncryptedData"

The problem is with showInstallPrompt. I'm using the following code:

        int requestCode = 7;
        string referrer = "InstallApiActivity";

        AndroidJavaClass postInstallIntentClass = new AndroidJavaClass("android.content.Intent");
        AndroidJavaObject postInstallIntentObject = new AndroidJavaObject("android.content.Intent");
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");

        AndroidJavaObject uri = uriClass.CallStatic<AndroidJavaObject>("parse", "https://techcookies.net/it.megasoft78.wordsjungle");

        postInstallIntentObject.Call<AndroidJavaObject>("setAction", postInstallIntentClass.GetStatic<string>("ACTION_VIEW"));
        postInstallIntentObject.Call<AndroidJavaObject>("addCategory", postInstallIntentClass.GetStatic<string>("CATEGORY_BROWSABLE"));
        postInstallIntentObject.Call<AndroidJavaObject>("setData", uri);

        postInstallIntentObject.Call<AndroidJavaObject>("putExtra", "data", "MyEncryptedData");

        instantAppsClass.CallStatic<bool>("showInstallPrompt", currentActivity, postInstallIntentObject, requestCode, referrer);

It seems is not passing the extras when I click Open after I installed from the showInstallPrompt screen.

Any idea how to solve it?

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 28, 2018

Anyway my game is live here:
Word Jungle Instant

The problem is that it seems not working consistently between devices.
On some devices it works on other it give back 404 on the browser.
Is it because Google is doing some kind of caching/indexing of the links?
I published it this morning and I expect it to be available everywhere but it's not the case. :(

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented May 29, 2018

Congratulations on getting your Unity game published in Play Console! I played it tonight on my Nexus 6 and it worked great!

I'm able to answer a couple questions now, and I'll investigate the others when I'm in the office tomorrow.

About the option I think it was explained well. What I did is use the URL-less option and click save but it didnt' add the intent-filter to my AndroidManifest.xml.

Thank you for clarifying what you were trying to accomplish. The behavior you observed is working as intended: with the URL-less option it should not add a view intent filter to the Manifest. I'll try to improve the documentation within the plugin to make this clearer.

Is this plugin going to support the possibility to detect is it's an Instant app and to show the Install prompt like in this link? https://developer.android.com/topic/google-play-instant/reference#showinstallprompt

Since your game has the install prompt, it seems like you may have solved this one already. Just in case, if you're wondering about having script code that is conditioned on whether it is a build of the instant app, you can do this today with

#if PLAY_INSTANT
  // instant only code
#endif
@megasoft78

This comment has been minimized.

Copy link
Author

commented May 29, 2018

Hi,
thank you. :)
I solved most of my issues. I have only the following ones:

  1. How to pass game state between instant game and installed one? I'm using post install intent but it doesn't seem to work. I check on the documentation that on Android 8.1 it will be automatic but for previous version I have to manually do it. Could you provide an example on how to do it or even some method in the library to pass the data?

  2. How can I use the built in url (https://instant.apps/it.megasoft78.wordsjungle) instead of my own domain? When I try to upload the apk it doesn't allow me as it say the verification fail.

  3. Is it expected after publishing to have 1-2 days when the instant app doesn't properly work? It seems during this period some people see the "Try Now" button and other don't see it. Some people even see the "Try Now" button but when they click on it they get a 404 error from the browser.

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 29, 2018

Hi again,
following the guide it looks like it's possible to use the Launch API like suggested in this link:
https://developer.android.com/topic/google-play-instant/getting-started/convert-to-instant-app#provide-url-access

The problem is that it redirect to https://instant.app/it.megasoft78.wordsjungle with the following error :

image

It doesn't work on Android Oreo because of the security restrictions.
What am I doing wrong?

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented May 30, 2018

Hi, I'll provide an update on some of your questions while I investigate the others.

How to pass game state between instant game and installed one? I'm using post install intent but it doesn't seem to work.

Do you mind trying this again? According to one of my coworkers this feature may have been only partially available before today, so it may be that it will work now. If not, there's something else happening here.

Regarding the certificate issue:

I see that you created the file at https://techcookies.net/.well-known/assetlinks.json and I ran the test at https://developers.google.com/digital-asset-links/tools/generator - it passes for the app package fingerprint you specified in the assetlinks.json file. I looked at your APK's CERT.RSA and the SHA256 fingerprint seems to be correct. I'll keep trying to determine the root cause.

How can I use the built in url (https://instant.apps/it.megasoft78.wordsjungle) instead of my own domain? When I try to upload the apk it doesn't allow me as it say the verification fail.

The way it's supposed to work is for you to completely remove the VIEW intent-filter and default-url from your AndroidManifest.xml and upload the zipped APK that way. If you do that do you get a verification failure? If not, https://instant.app/it.megasoft78.wordsjungle should then start to work (it make take a few hours to propagate).

@megasoft78

This comment has been minimized.

Copy link
Author

commented May 30, 2018

Hi,
About post install intent are saying that it doesn't work because Google Play Store / Google Play Services need an update that happen just today to pass that extras to the post intent?
Or you mean that preferences will be transfered automatically when the users install it? As far as I know that feature should work only for Android 8.1. Anyway I'll try it again an see if it's working. :)

About the issue with link, I'd like to not use my own domain for that because if I want to publish new instant game I have to setup one subdomain for each one. I would prefer to use the built in one. The problem is that I tried and after few hours I published it doesn't show the Try Now button at all. What I did is removing intent-filter and default-url from AndroidManifest.xml and leave it only the intent-filter for installed one.
Even with my own domain I'm experiencing issues. Even after 10 hours some people report they don't see the try button on some devices and they see it on other. I checked with them about configuration on the device to make the instant app enabled but still don't see Try Now button. The major problem is that some people see the Try Now button but when they click on it, instead of open the game it open the browser to my website with a 404 error.

Not sure what to do. I'm a bit confused. :(

@vkreal

This comment has been minimized.

Copy link

commented Jun 27, 2018

I am having same issue as described by @megasoft78 above. Anyone can help with making the URL-less work? Thanks!

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented Jun 27, 2018

Regarding Try Now not showing up for a just-published app: it may be that the local cache of instant apps is out of sync since the cache is only refreshed once per day. To force a local cache sync go to Android Settings -> Google -> Instant Apps and disable and then re-enable instant apps. (On some devices this may be accomplished by switching the Instant Apps account to "None" and then re-selecting the Google Account to use.)

@thanwah

This comment has been minimized.

Copy link
Collaborator

commented Jul 11, 2018

Closing this. Please reopen or create a new issue if this is still a problem. Thanks!

@thanwah thanwah closed this Jul 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.