如何通过ADB启动Unity Android应用程序?

发布于 2025-02-08 06:48:23 字数 4058 浏览 1 评论 0原文

我试图弄清楚如何从ADB启动Unity应用程序,理想情况下,我可以将自动意图参数传递给自动设备测试。到目前为止,我只是启动 通过ADB陷入困境。我很清楚这是可能的,而且必须是可能的,因为诸如sidequels之类的应用程序能够在完全相同的应用程序上完成此操作,我无法完成此工作在。

我目前正在使用未修改的统一Android清单,我可以从Pixel 4A正常启动,并且可以从Sidequest启动。我尝试了以下命令,许多人声称应该使用

 adb shell am start -n com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity

 adb shell am start -n "com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity"

 adb -d shell am start -f 0x10000000 -n com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity

 adb shell am start -n com.Futurus.AIntent/unityplayer.UnityActivity -a android.intent.action.MAIN

我尝试过的每个命令声称活动类不存在的每个命令,尽管它与我在Android Studio中查看的汇编中相匹配。如果我尝试resolve-activity我得到找不到活动,它似乎不可能是正确的,因为该应用程序在通过TAP或Sidequest打开时运行。

我是一个完全的损失,在下面,我从Android Studio复制了分析的清单。据我所知,我要正确执行起点命令,但是对于我的一生,它不会打开。非常感谢

我在Win11上使用Unity 2021.3.4f1,如果有任何重要的话,请通过PowerShell进行ADB。

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="0.1"
    android:installLocation="2"
    android:compileSdkVersion="30"
    android:compileSdkVersionCodename="11"
    package="com.Futurus.AIntentTest"
    platformBuildVersionCode="30"
    platformBuildVersionName="11">

    <uses-sdk
        android:minSdkVersion="22"
        android:targetSdkVersion="30" />

    <supports-screens
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-feature
        android:glEsVersion="0x30000" />

    <uses-feature
        android:name="android.hardware.vulkan.version"
        android:required="false" />

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

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

    <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" />

    <application
        android:label="@ref/0x7f030005"
        android:icon="@ref/0x7f020000"
        android:extractNativeLibs="true">

        <activity
            android:theme="@ref/0x7f040001"
            android:name="com.unity3d.player.UnityPlayerActivity"
            android:launchMode="2"
            android:screenOrientation="10"
            android:configChanges="0x40003fff"
            android:hardwareAccelerated="false"
            android:resizeableActivity="false">

            <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" />

            <meta-data
                android:name="android.notch_support"
                android:value="true" />
        </activity>

        <meta-data
            android:name="unity.splash-mode"
            android:value="0" />

        <meta-data
            android:name="unity.splash-enable"
            android:value="true" />

        <meta-data
            android:name="unity.launch-fullscreen"
            android:value="true" />

        <meta-data
            android:name="unity.allow-resizable-window"
            android:value="false" />

        <meta-data
            android:name="notch.config"
            android:value="portrait|landscape" />
    </application>
</manifest>

I'm trying to figure out how to start a Unity app from ADB, ideally so I can pass custom intent parameters for automated device testing. So far, I'm stuck just on starting a Unity app via ADB. I am well aware that this is possible, and it MUST be possible because apps like Sidequest are able to accomplish this on the exact same app, on the exact same phone, that I can't make this work on.

I'm currently using an unmodified Unity Android Manifest, which I can confirm both launches normally from a Pixel 4a and can launch from Sidequest. I've tried the following commands that many people claim should work

 adb shell am start -n com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity

 adb shell am start -n "com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity"

 adb -d shell am start -f 0x10000000 -n com.Futurus.AIntent/com.unity3d.player.UnityPlayerActivity

 adb shell am start -n com.Futurus.AIntent/unityplayer.UnityActivity -a android.intent.action.MAIN

Every single command I've tried claims that the activity class does not exist, despite the fact that it matches what's in the compiled manifest that I looked at in Android Studio. If I try to resolve-activity I get No activity found which seems like it cannot possibly be true because the app runs when opened via tap or Sidequest.

I'm a complete loss, below I've copy-pasted the analyzed manifest from Android Studio. As best as I can tell, I'm performing the start command correctly but for the life of me it will not open. Any help is greatly appreciated

I'm using Unity 2021.3.4f1 on Win11, ADB through Powershell if any of that matters.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="0.1"
    android:installLocation="2"
    android:compileSdkVersion="30"
    android:compileSdkVersionCodename="11"
    package="com.Futurus.AIntentTest"
    platformBuildVersionCode="30"
    platformBuildVersionName="11">

    <uses-sdk
        android:minSdkVersion="22"
        android:targetSdkVersion="30" />

    <supports-screens
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-feature
        android:glEsVersion="0x30000" />

    <uses-feature
        android:name="android.hardware.vulkan.version"
        android:required="false" />

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

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

    <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" />

    <application
        android:label="@ref/0x7f030005"
        android:icon="@ref/0x7f020000"
        android:extractNativeLibs="true">

        <activity
            android:theme="@ref/0x7f040001"
            android:name="com.unity3d.player.UnityPlayerActivity"
            android:launchMode="2"
            android:screenOrientation="10"
            android:configChanges="0x40003fff"
            android:hardwareAccelerated="false"
            android:resizeableActivity="false">

            <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" />

            <meta-data
                android:name="android.notch_support"
                android:value="true" />
        </activity>

        <meta-data
            android:name="unity.splash-mode"
            android:value="0" />

        <meta-data
            android:name="unity.splash-enable"
            android:value="true" />

        <meta-data
            android:name="unity.launch-fullscreen"
            android:value="true" />

        <meta-data
            android:name="unity.allow-resizable-window"
            android:value="false" />

        <meta-data
            android:name="notch.config"
            android:value="portrait|landscape" />
    </application>
</manifest>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与酒说心事 2025-02-15 06:48:23

您正在做所有的事情,不错的教程。只是我正在寻找的东西!

根据卢克的评论:

我们的软件包是com.futurus.ainttestest,但是您尝试过的命令不包括“测试”部分 - 您是否尝试过ADB Shell Am Start -n com.futurus.aintenttest/com.unity3d.player.unityplayerActivity?<<<<< /p>

问题只是班级名称的小问题。

我将其添加为答案,以使解决方案更加可见。如果卢克在这里添加自己的答案;我会很高兴删除这个。

You are doing everything right, nice tutorial. Just the thing I was looking for!

As per Luke's comment:

our package is com.Futurus.AIntentTest but the commands you have tried do not include the "Test" part - have you tried adb shell am start -n com.Futurus.AIntentTest/com.unity3d.player.UnityPlayerActivity?

Problem was just a small issue with class names.

I added this as an answer, for making the solution more visible. If luke adds his own answer here; I will happily delete this one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文