Android Wear-Gradle依赖性问题“无法解析符号" [英] Android Wear - Gradle dependency issues "Cannot resolve symbol"

查看:97
本文介绍了Android Wear-Gradle依赖性问题“无法解析符号"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照此处的说明进行操作,以使用移动设备构建简单的应用并在Android Studio中佩戴组件.我的移动活动中有以下代码,试图调用Wear模块中的MyWearActivity:

I followed the instructions here to build a simple app with mobile and wear components in Android Studio. I have the following code in my mobile activity, trying to call MyWearActivity which is in wear module:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    Intent intent = new Intent(this, MyWearActivity.class);
    startActivity(intent);
}

我的移动build.gradle文件具有以下依赖性:

My mobile build.gradle file has the following dependencies:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.support:wearable:+'
}

但是,我收到以下错误无法解析符号MyWearActivity",试图从Android Studio运行移动"运行配置.我认为wearApp project(':wear')位会处理移动设备问题依赖磨损,但似乎没有.任何人都可以找出我要去哪里的地方吗?谢谢

However, I am getting the following error "Cannot resolve symbol MyWearActivity', trying to run the "mobile" run configuration from Android Studio. I would think the wearApp project(':wear') bit would take care of the mobile dependency on wear but it seems not. Can anyone identify where I'm going wrong? Thanks

推荐答案

不,将Wear模块和Mobile模块视为两个完全不同的apk或应用(因为它们是).您不会直接从移动应用中调用Wear模块中的活动. Wear应用是通过用户交互启动的.您到底想做什么?

No, think of the Wear module and the Mobile module as two completely different apks or apps (because they are). You do not directly call to the activities in the Wear module from the Mobile app. The wear app is started through user interaction. What exactly are you trying to do?

好吧,根据您在下面的评论,问题仍然在于您无法从Mobile应用程序调用WearActivity,因为该应用程序位于未链接在一起的其他库/应用程序中. Nickjm的答案中上面的示例代码是一个好的开始.

Ok, based on your comment below, the problem is still that you can't call a WearActivity from the Mobile app since that is in a different library/app that is not linked together. The example code from above in the answer from Nickjm is a good start.

这篇关于Android Wear-Gradle依赖性问题“无法解析符号"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆