我想从MessageActivity中的“聊天”模块调用活动(ChatActivity),但它是另一个模块(卖方)的一部分。但是当我像这样对卖方模块添加依赖项时:
implementation project(path: ':chat')
我收到此错误
ERROR: Unable to resolve dependency for ':seller@debugAndroidTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: seller
这是我的build.gradle(module:seller)文件
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.seller"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.ncapdevi:frag-nav:1.0.3'
implementation 'com.roughike:bottom-bar:1.3.9'
implementation('com.mikepenz:materialdrawer:5.3.1@aar') {
transitive = true
}
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.1.3'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.google.firebase:firebase-firestore:21.4.1'
implementation 'com.google.firebase:firebase-core:17.2.3'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-database:19.2.1'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation project(path: ':app')
}
这是我的项目settings.gradle
rootProject.name='commercetest'
include ':app', ':seller'
这是我的MessageActivity文件:
package com.example.seller;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
public class MessageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(MessageActivity.this, ChatActivity.class);
MessageActivity.this.startActivity(intent);
}
}
为什么一直发送错误。是否有链接,在哪里可以找到信息?
聊天模块应该是一个android库
更换
apply plugin: 'com.android.application'
与
apply plugin: 'com.android.library'
applicationId "com.example.chat"
从模块的build.grade中删除
另外,您还应该将ChatActivity添加到清单中,例如:
<activity android:name=".ChatActivity">
<intent-filter>
<action android:name="com.example.seller.MessageActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
这应该工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句