Crash loading WearableActivity

后端 未结 2 966
一向
一向 2021-01-21 00:43

I am receiving a crash with the following message while migrating an AppCompatActivity to a WearableActivity.

Caused by: java.lang.IllegalStateException:

相关标签:
2条回答
  • 2021-01-21 01:22

    Without seeing your AndroidManifest the only suggestion I can make is the following:

    uses-library should be application level, not manifest level. Your AndroidManifest should look like this:

    <manifest
        package="com.yourpackage.app_package"
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <uses-feature android:name="android.hardware.type.watch"/>
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.DeviceDefault">
    
            <uses-library android:name="com.google.android.wearable" android:required="false" />
    
            <activity
            ....
            </activity>
       </application>
    </manifest>
    

    Consider: http://developer.android.com/guide/topics/manifest/uses-library-element.html

    0 讨论(0)
  • 2021-01-21 01:40

    Might want to useAmbientMode.AmbientCallbackProvider instead of WearableActivity.

    It is the new preferred method and it still gives you all the stuff with WearableActivity but you can keep using AppCompatActivity.

    Official docs call out the details (and example code).

    0 讨论(0)
提交回复
热议问题