本文介绍了错误:包不存在,谷歌Android手机后台启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有在这里的几个类似的问题,但我无法找到一个解决办法。

我使用的是谷歌手机后台启动并一切正常,直到我想尝试从GCMintentService.java发送通知。如果我称之为

 意图resultIntent =新意图(这一点,MyActivity.class);

我得到MyActivity应用程式模块中不存在的错误。我是pretty知道我应该增加类似

 编制项目(':应用程序)

要保存GCMintentService.java,但如果我这样做,我得到一个错误,指出应用程序的核心模块的gradle这个dependances是不是图书馆?

下面是核心模块gradle这个依赖关系

  {相关性
    编译('com.google.cloud.backend:mobilebackend:v1-1.19.0-快照){
        排除(组:org.apache.httpcomponents',模块:HttpClient的')
    }
    编译com.android.support:appcompat-v7:20.+
    编译com.google.api客户端:谷歌API的客户端Android版:1.19.0
    编译com.google.http客户端:谷歌的HTTP客户端:1.19.0
    编译('com.google.http客户端:谷歌的HTTP客户端Android版:1.19.0'){
        排除(组:com.google.android',模块:'机器人')
        排除(组:org.apache.httpcomponents',模块:HttpClient的')
    }
    编译com.google.http客户端:谷歌-HTTP-客户GSON:1.19.0
    编译com.google.http客户端:谷歌-HTTP客户端 - 杰克逊:1.19.0
    编译com.google.http客户端:谷歌-HTTP-客户jackson2:1.19.0
    编译com.google.oauth客户端:谷歌OAuth的客户:1.19.0
    编译com.google code.gson:GSON:2.2.4
    编译com.fasterxml.jackson.core:杰克逊核心:2.1.3
    编译组织codehaus.jackson:杰克逊核心翔升:1.9.13
    编译com.google code.findbugs:JSR305:1.3.9
    编译com.mcxiaoke.volley:图书馆:1.0 + @ AAR
    编译com.google.android.gms:游戏服务:52年4月4日
}


解决方案

如果你的应用的项目不是一个库(如果它使用申请插件:'com.android.application而不是应用插件:'com.android.library),那么其他的模块不能依赖在上面。你只能靠库,而不是应用模块。

您可能需要C,它一切都取决于把您共同$ C $和打破它到一个单独的模块,核心模块与您的应用程序模块既可以依靠的人。

There are a few similar questions on here but I am having trouble finding a solution.

I am using the google mobile backend starter https://cloud.google.com/cloud/samples/mbs/ and everything works until I want to try and send notifications from GCMintentService.java. If I call

Intent resultIntent = new Intent(this, MyActivity.class);

I get an error that MyActivity in the App module does not exist. I am pretty sure I should add something like

compile project(':app')

to the gradle dependances of the core module that holds GCMintentService.java but if I do I get an error saying that app is not a library?

Here is the core module gradle dependancies

dependencies {
    compile('com.google.cloud.backend:mobilebackend:v1-1.19.0-SNAPSHOT') {
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.api-client:google-api-client-android:1.19.0'
    compile 'com.google.http-client:google-http-client:1.19.0'
    compile('com.google.http-client:google-http-client-android:1.19.0') {
        exclude(group: 'com.google.android', module: 'android')
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    compile 'com.google.http-client:google-http-client-gson:1.19.0'
    compile 'com.google.http-client:google-http-client-jackson:1.19.0'
    compile 'com.google.http-client:google-http-client-jackson2:1.19.0'
    compile 'com.google.oauth-client:google-oauth-client:1.19.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.fasterxml.jackson.core:jackson-core:2.1.3'
    compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
    compile 'com.google.code.findbugs:jsr305:1.3.9'
    compile 'com.mcxiaoke.volley:library:1.0.+@aar'
    compile 'com.google.android.gms:play-services:4.4.52'
}
解决方案

If your app project isn't a library (if it uses apply plugin: 'com.android.application' instead of apply plugin: 'com.android.library'), then other modules can't depend on it. You can only depend on libraries, not application modules.

You may need to take your common code that everything depends on and break it out into a separate module that both your core module and your app module can depend on.

这篇关于错误:包不存在,谷歌Android手机后台启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:20