Is it possible to discover and run third-party And

2020-05-26 17:05发布

I'm currently trying to learn about Android instant apps. Since I don't own any real devices that support them, I'm using the emulator (from Android Studio 3.0 Canary 9). I can successfully run "toy" instant apps (like this) on my emulated Nexus 5x (with Play Store), so I believe that my development environment is configured correctly.

However, I was curious to learn about the discovery process for third-party apps, and find out what the user experience is like. Lacking a suitable device of my own, I used the emulated Chrome browser to search for sites (like Stack Exchange) that have instant apps enabled. But these searches only give me the usual websites (not instant apps).

I read this post with great interest, because it seems to suggest that this should work. However, those answers didn't seem to help me.

  • I'm in Australia, which should be one of the countries where Instant Apps are supported.
  • As suggested in one answer, I've tried sending links that should open in instant apps in emails and then clicking on them, but it still just sends me to a browser link.
  • The answer about DAL verification is interesting, but doesn't seem like it should apply when opening links in a browser?

The API 24 and API 26 emulated devices (both of which include the Play Store) are currently in somewhat different conditions, probably because I've been trying all sorts of tricks to make it work. (TLDR: Nothing's working for me.)

  • On the API 24 emulated device, if I type adb shell pm list packages grep "com.google.android.instantapps.supervisor" then it outputs package:com.google.android.instantapps.supervisor as one answer suggests (but it still doesn't work).

  • The API 24 device has Google Play services for Instant Apps (version 1.9-sdk-155682639) installed.

  • The API 24 device has a "lightning bolt" notification at the top of the screen saying "Development Mode Active": URLs will be routed to Dev Manager in order to launch Instant Apps locally. Uninstall Dev Manager to disable Development Mode.

  • On the API 24 device, Settings -> Google -> Instant Apps, instant apps is set to true

  • On the API 26 emulated device, if I type adb shell pm list packages grep "com.google.android.instantapps.supervisor" returns nothing

  • On the API 26 device, Google Play services for Instant Apps isn't installed, and there isn't any "lightning bolt" notification either

  • On the API 26 device, Settings -> Google doesn't list Instant Apps (so there's nothing to set)

Here are some additional details, in case they're relevant:

  • My development machine runs Windows 10 (not by choice)
  • The emulated devices are Nexus 5x (API 24 and 26) with Play Store
  • I also tried the "x86" images, since some people recommended them for Windows, but they didn't work either. (This may be because the "x86" images don't come with Play Store, which I think is required for Instant Apps?)
  • I'm logged into a real Google user account on the emulated devices.

With the development environment I've set up now, I can continue to develop my own instant app, deploy it on my own emulated devices, and test it. I was really just curious to see how other people's instant apps work. And another post (linked above) suggested that I should be able to do this.

So here's my question: Is it possible to discover and open third-party Instant Apps on an emulated device (and if so, how)?

2条回答
We Are One
2楼-- · 2020-05-26 17:14

When you enable Android Instant App from App Link Assistant, your Activity that you want to directly launch (or have information on your website) gets modified as below:

<activity
            android:name=".View.Activity.AboutActivity"
            android:parentActivityName="com.example1.uddhav.stopwatch.View.Activity.AboutActivity">
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

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

                <data
                    android:scheme="http"
                    android:host="your_web_address" />
            </intent-filter>
        </activity>

Hence, when you get third-party apps, you must modify AndroidManifest.xml file as above.

And, to be able to link your instant activity (for eg, AboutActivity), you have to save the generated assetlinks.json inside the .well-known folder of your website root folder as <your_web_site>/.well-known/assetlinks.json

There is a reverse engineering tool that lets you modify AndroidManifest.xml file.

Note: As you don't need uses-permission tag for Instant apps, you don't need to resign it.

As you are not handling AppLink intent, you don't need

// ATTENTION: This was auto-generated to handle app links.
Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Uri appLinkData = appLinkIntent.getData();

So, up to my understanding, it is possible to run third-party Android instant Apps on supported emulator devices. I apologize if I misunderstood your question.

查看更多
三岁会撩人
3楼-- · 2020-05-26 17:28

Is it possible to discover and open third-party Instant Apps on an emulated device (and if so, how)?

At present, no. :( There are security restrictions in place preventing emulated devices from using various Google services. If you check the log, you might find a message similar to "io.grpc.StatusException: INVALID_ARGUMENT: Application credential header not valid. Please fix the client to pass a valid application credential header."

On the API 26 emulated device, if I type adb shell pm list packages grep "com.google.android.instantapps.supervisor" returns nothing

FYI, Supervisor isn't used for Android O.

查看更多
登录 后发表回答