You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android Studio Narwhal Journey功能运行报错:请求的认证权限范围不足

Android Studio Narwhal Journey功能运行报错:请求的认证权限范围不足

我最近在测试Android Studio Narwhal Feature Drop(2025.1.3 Canary 2)的新Journey功能,已经完成谷歌账号登录、生成并配置了Gemini API Key,但运行journey.xml时直接触发了权限错误,完整错误日志如下:

Main first Journey (192.168.1.101:5555) > initializationError FAILED
com.android.tools.journeys.testengine.robo.JourneyExecutionException: An unexpected error occurred during journey execution: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Request had insufficient authentication scopes. [Reason=UNKNOWN_FAILURE]
at app//com.android.tools.journeys.testengine.robo.Proxy.executeJourney(Proxy.kt:96)
at app//com.android.tools.journeys.testengine.JourneysTestEngine.execute(JourneysTestEngine.kt:100)
Caused by: com.google.appcrawler.platform.client.GrpcClient$ServerErrorException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Request had insufficient authentication scopes.
at app//com.google.appcrawler.platform.client.GrpcClient.doResumableCrawl(GrpcClient.java:273)
at app//com.google.appcrawler.platform.client.GrpcClient.startForward(GrpcClient.java:170)
at app//com.android.tools.journeys.testengine.robo.Proxy.connectToCrawlerBackend(Proxy.kt:409)
at app//com.android.tools.journeys.testengine.robo.Proxy.executeJourney(Proxy.kt:87)
... 1 more
Caused by: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Request had insufficient authentication scopes.
at app//io.grpc.Status.asRuntimeException(Status.java:532)
at app//io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:481)
at app//io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
at app//io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
at app//io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
at app//io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:564)
at app//io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:72)
at app//io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:729)
at app//io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:710)
at app//io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at app//io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base@21.0.6/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base@21.0.6/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base@21.0.6/java.lang.Thread.run(Unknown Source)

<ijLog><event type='afterSuite'><ijLogEol/>
 <test id='1.2' parentId='1.1'><ijLogEol/>
 <descriptor name='main_first_journey' displayName='Main first Journey (192.168.1.101:5555)' className='main_first_journey' /><ijLogEol/>
 <result resultType='FAILURE' startTime='1763982572263' endTime='1763982588657'><ijLogEol/>
 <failureType>error</failureType><ijLogEol/>
 </result><ijLogEol/>
 </test><ijLogEol/></event></ijLog>
<ijLog><event type='afterSuite'><ijLogEol/>
 <test id='1.1' parentId=':app:validateDebugJourneysTest'><ijLogEol/>
 <descriptor name='Gradle Test Executor 1' displayName='Gradle Test Executor 1' className='' /><ijLogEol/>
 <result resultType='FAILURE' startTime='1763982571927' endTime='1763982588659'><ijLogEol/>
 <failureType>error</failureType><ijLogEol/>
 </result><ijLogEol/>
 </test><ijLogEol/></event></ijLog>
<ijLog><event type='afterSuite'><ijLogEol/>
 <test id=':app:validateDebugJourneysTest' parentId=''><ijLogEol/>
 <descriptor name='Gradle Test Run :app:validateDebugJourneysTest' displayName='Gradle Test Run :app:validateDebugJourneysTest' className='' /><ijLogEol/>
 <result resultType='FAILURE' startTime='1763982569525' endTime='1763982589267'><ijLogEol/>
 <failureType>error</failureType><ijLogEol/>
 </result><ijLogEol/>
 </test><ijLogEol/></event></ijLog>

问题原因分析

核心错误信息PERMISSION_DENIED: Request had insufficient authentication scopes已经点明了问题:虽然完成了账号登录和API Key配置,但关联的谷歌云项目凭据缺少Journey功能所需的特定权限范围,导致后端请求被拒绝。

解决步骤

  1. 补全谷歌云项目权限范围

    • 打开谷歌云控制台,定位到你绑定Gemini API Key的项目
    • 进入「API和服务」→「OAuth同意屏幕」,确认你的谷歌账号已添加为该项目的测试用户(内部项目可跳过此步)
    • 进入「API和服务」→「凭据」,找到对应OAuth客户端ID(或服务账号),点击「编辑」添加权限范围:
      • 至少需要添加https://www.googleapis.com/auth/cloud-platform基础云平台权限,或Journey依赖的Google App Crawler专属权限
    • 保存配置后,若需更新凭据则重新生成,再回到Android Studio同步配置
  2. 启用必要的后端API

    • 在谷歌云控制台的「API库」中搜索Google App Crawler API,确保该API已启用(Journey功能依赖此API完成自动化爬取逻辑)
  3. 重置Android Studio缓存凭据

    • 打开Android Studio的SettingsAppearance & BehaviorSystem SettingsPasswords,删除谷歌账号的缓存凭据
    • 重启Android Studio,重新登录谷歌账号,再尝试运行Journey任务

如果以上步骤仍未解决问题,可以尝试创建全新的谷歌云项目,重新生成Gemini API Key并配置,旧项目的权限遗留缓存偶尔会导致这类难以排查的权限问题。

火山引擎 最新活动