Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在Wear设备上启动嵌入式Wear应用程序的活动_Android_Android Activity_Classnotfoundexception_Wear Os - Fatal编程技术网

Android 无法在Wear设备上启动嵌入式Wear应用程序的活动

Android 无法在Wear设备上启动嵌入式Wear应用程序的活动,android,android-activity,classnotfoundexception,wear-os,Android,Android Activity,Classnotfoundexception,Wear Os,当我将APK推到带有嵌入式Wear应用程序的手机上,然后转到开始…,然后尝试运行我的应用程序时,它会在手表上崩溃。该异常是ClassNotFoundException 09-18 14:53:17.678: E/AndroidRuntime(2391): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.WearActivity}: java.lang.Clas

当我将APK推到带有嵌入式Wear应用程序的手机上,然后转到开始…,然后尝试运行我的应用程序时,它会在手表上崩溃。该异常是ClassNotFoundException

09-18 14:53:17.678: E/AndroidRuntime(2391): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.WearActivity}: java.lang.ClassNotFoundException: Didn't find class "com.myapp.WearActivity" on path: DexPathList[[zip file "/data/app/com.myapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp-1, /vendor/lib, /system/lib]]
我已在可穿戴AndroidManifest.xml文件中声明了此活动

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.DeviceDefault" >

   <activity
        android:name=".WearActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

真的不知道还有什么会阻止操作系统找到活动。有什么想法吗?

结果是以下build.gradle条目相互冲突

移动

compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.0.77'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
磨损

compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.support:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:5.0.77'

通过明确声明版本号,问题就消失了

移动

compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.0.77'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
磨损

compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.support:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:5.0.77'

com.myapp
WearActivity
类的有效软件包吗?请检查您的
WearActivity
位于何处。在我的问题中,我提到我已经这样做了:)您没有发布您的活动类,所以只需要确定:)您说您将应用程序推到手机上,因此它“应该”也安装在Android Wear上。你确定手表上安装了最新版本的可穿戴应用程序吗?也许有一些旧版本没有这个
WearActivity
?尝试从watch卸载它,看看是否可以再次正确安装。顺便问一下:当你按下可穿戴apk(用调试键签名)直接观看(不依赖于从手机安装签名apk)时,它是否起作用?请告诉我-它将消除一些情况:)目前它还没有安装在手机的手表上。故障排除!你有没有注意到你的手表上有旧的apk?也许这就是为什么它没有一些预期的课程?对我来说,我面临着一个奇怪的问题。。。当我试图从手机上卸载应用程序时(它也会卸载磨损版本),我会安装一个新的签名apk。但是手表中的自动安装,实际上是安装了最后一个(旧)版本!我还尝试在手机上清除android wear应用程序的数据。只有当我在两台设备上明确卸载应用程序并卸载android wear应用程序本身(负责连接手表的应用程序)时,问题才得以解决。然后重新安装!我从未注意到这一点,但我确实注意到,应用程序通过蓝牙将apk传输到可穿戴设备时,有时会出现延迟。通常,它会在成功安装后退出旧应用程序。我还注意到gradle中有一些bug,我可以通过
gradle--stop
然后清理项目来修复它们