Issue
I want to call an activity (ChatActivity) from Chat module in MessageActivity which is a part of another module (seller). But when I add a dependency on the seller module like this:
implementation project(path: ':chat')
I received this error
':seller@debugAndroidTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: seller
Here is my build.gradle (module:seller) file
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')
}
Here is my project settings.gradle
rootProject.name='commercetest'
include ':app', ':seller'
Here is my MessageActivity file :
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);
}
}
Why is it keep sending an error. and is there a link, where to find the information?
Solution
The Chat module should be an android Library
Replace
apply plugin: 'com.android.application'
with
apply plugin: 'com.android.library'
remove
applicationId "com.example.chat"
from module's build.gradeAlso you should add ChatActivity to the Manifest, for example :
<activity android:name=".ChatActivity"> <intent-filter> <action android:name="com.example.seller.MessageActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
This should work.
Answered By - Wael Jomni
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.