簡體   English   中英

使用 adb shell am start 啟動 android 應用程序時出現錯誤“組件名稱錯誤”

[英]error "bad component name" when launching android app with adb shell am start

我正在嘗試使用 adb shell am 啟動一項活動,但我總是遇到錯誤組件名稱錯誤。

 C:\Users\EnzoAbjean\Documents\Automatisation\TelinkSH-Enzo\qa-automatisation-tool>adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.mesh.ui.DeviceProvisionActivity

Exception occurred while executing 'start':
java.lang.IllegalArgumentException: Bad component name: com.telink.ble.mesh.ui.DeviceProvisionActivity

這是我的清單:

 <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         package="com.telink.ble.mesh.demo">
      <application
             android:name="com.telink.ble.mesh.LightingApplication"
            android:allowBackup="true"
             android:icon="@mipmap/ic_launcher"
             android:label="@string/app_name"
             android:requestLegacyExternalStorage="true"
             android:supportsRtl="true"
             android:theme="@style/AppTheme"
             tools:ignore="GoogleAppIndexingWarning">
       <activity
                android:name="com.telink.ble.mesh.ui.DeviceProvisionActivity"
                 android:screenOrientation="portrait"
                 android:windowSoftInputMode="stateAlwaysHidden"
                 tools:ignore="LockedOrientationActivity" />
 

我真的不知道它是如何不起作用的。 我之前嘗試將 package 名稱為“com.telink.ble.mesh.demo”,但沒有。

添加exported和意圖過濾器:

   <activity
            android:name="com.telink.ble.mesh.ui.DeviceProvisionActivity"
             android:screenOrientation="portrait"
             android:windowSoftInputMode="stateAlwaysHidden"
             tools:ignore="LockedOrientationActivity"
             android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>

    </activity>
             

那么你應該能夠啟動

am start -n com.telink.ble.mesh.demo/com.telink.ble.mesh.ui.DeviceProvisionActivity

正如@Robert 在評論中提到的那樣。

android {
compileSdkVersion 29
buildToolsVersion = '28.0.3'

defaultConfig {
    applicationId "com.telink.ble.smart.home"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 3
    versionName "1.0.2"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

現在我的命令行是adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.smart.home/com.telink.ble.mesh.ui.DeviceProvisionActivity

我查看了我的 build.gradle 並在 defaultConfig 中找到了一個新路徑:“com.telink.ble.smart.home”並嘗試了這條路徑的工作。 在我的清單中,我必須為我的活動添加一個導出。 感謝@Robert 和@Diego Torres Milano 的回答。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM