aws-amplify / amplify-android

The fastest and easiest way to use AWS from your Android app.
https://docs.amplify.aws/lib/q/platform/android/
Apache License 2.0
250 stars 117 forks source link

Can't access generated modules in multi modules app #1631

Closed reberthkss closed 2 years ago

reberthkss commented 2 years ago

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

GraphQL API

Gradle script dependencies

```groovy // Put output below this line apply plugin: "com.android.application" apply plugin: "kotlin-android" apply plugin: "kotlin-android-extensions" apply plugin: "kotlin-kapt" apply plugin: "androidx.navigation.safeargs" android { compileSdkVersion rootProject.ext.compile_sdk_version buildToolsVersion rootProject.ext.build_tools_version defaultConfig { applicationId "com.example.shoplist" minSdkVersion rootProject.ext.min_sdk_version targetSdkVersion rootProject.ext.target_sdk_version testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true multiDexEnabled true javaCompileOptions { annotationProcessorOptions { arguments << [ "room.schemaLocation": "$projectDir/schemas".toString(), "room.incremental": "true", "room.expandProjection": "true" ] } } repositories { google() mavenCentral() } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } sourceSets { main.java.srcDirs += "src/main/kotlin" test.java.srcDirs += "src/test/kotlin" } buildFeatures { viewBinding true dataBinding true } testOptions { unitTests.returnDefaultValues = true } } dependencies { implementation project(":core") implementation project(":core:viewmodel") implementation project(":core:di") implementation project(":authentication") implementation project(":authentication:authenticated") implementation project(":authentication:unauthenticated") implementation project(":main") implementation project(":main:dashboard") implementation project(':main:categorylist') implementation project(":createlist") // android core implementation androidx_core_deps.values() implementation android_fragment.values() implementation android_navigation.values() implementation android_lifecycle.values() implementation android_material_design.values() implementation room_db.values() implementation dagger.values() implementation rx_deps.values() // Amplify SDK implementation amplify.values() // kapt kapt kapt_lifecycle.values() kapt kapt_dagger.values() kapt kapt_room_db.values() // annotation processor kapt annotation_processor_dagger.values() // tests testImplementation tests.values() // android tests androidTestImplementation android_test.values() } // dependencies.gradle ext { core_ktx_version='1.7.0' android_framework_version='1.4.0' constraint_layout_version='2.1.2' fragment_version='1.4.0' nav_version='2.3.5' lifecycle_version='2.4.0' dagger_version='2.40.2' room_version='2.3.0' junit_version='4.+' android_junit_version='1.1.3' espresso_version='3.4.0' rx_core_version='2.2.6' rx_android_version='2.1.1' rx_kotlin_version='2.4.0' amplify_version = "1.31.0" androidx_core_deps = [ "core_ktx": "androidx.core:core-ktx:$core_ktx_version", "android_framework": "androidx.appcompat:appcompat:$android_framework_version", "constraint_layout": "androidx.constraintlayout:constraintlayout:$constraint_layout_version", ] amplify = [ "core": "com.amplifyframework:core:$amplify_version", "amplify_api": "com.amplifyframework:aws-api:$amplify_version", "amplify_datastore": "com.amplifyframework:aws-datastore:$amplify_version", "aws_auth": "com.amplifyframework:aws-auth-cognito:$amplify_version" ] android_fragment = [ "fragment": "androidx.fragment:fragment-ktx:$fragment_version", ] android_navigation = [ "core": "androidx.navigation:navigation-fragment-ktx:$nav_version", "ui": "androidx.navigation:navigation-ui-ktx:$nav_version", "dynamic_features": "androidx.navigation:navigation-dynamic-features-fragment:$nav_version" ] android_lifecycle = [ "view_model": "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version", "live_data": "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version", "saved_instance": "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" ] android_material_design = [ "core": "com.google.android.material:material:$android_framework_version", ] room_db = [ "core": "androidx.room:room-rxjava2:$roomVersion" ] rx_deps = [ "core": "io.reactivex.rxjava2:rxjava:$rx_core_version", "android": "io.reactivex.rxjava2:rxandroid:$rx_android_version", "kotlin": "io.reactivex.rxjava2:rxkotlin:$rx_kotlin_version" ] dagger = [ "core": "com.google.dagger:dagger-android:$dagger_version", "support": "com.google.dagger:dagger-android-support:$dagger_version" ] kapt_lifecycle = [ "core": "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" ] annotation_processor_dagger = [ "dagger2processor": "com.google.dagger:dagger-android-processor:$dagger_version", "dagger2compiler": "com.google.dagger:dagger-compiler:$dagger_version" ] kapt_dagger = [ "compiler": "com.google.dagger:dagger-compiler:$dagger_version" ] kapt_room_db = [ "core": "androidx.room:room-compiler:$room_version" ] tests = [ "junit": "junit:junit:$junit_version" ] android_test = [ "junit_androidx": "androidx.test.ext:junit:$android_junit_version", "espresso_androidx": "androidx.test.espresso:espresso-core:$espresso_version" ] } ```

Environment information

``` # Put output below this line ```

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

My generated models from amplify graphql api are not available to another modules. It may led to cause an circular reference error if i try to import app module inside of my modules.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

amplifyconfiguration.json

No response

GraphQL Schema

```graphql // Put your schema below this line ```

Additional information and screenshots

image
poojamat commented 2 years ago

You can create a post-models-codegen.js or post-models-codegen.sh file in amplify/hooks directory that has the logic to copy/move the generated files from app/src/main/java to your custom file location.

This should run the hook created after they run amplify codegen models. Here is how you can create command hooks.

reberthkss commented 2 years ago

nice! I will take a look!

div5yesh commented 2 years ago

@reberthkss Feel free to close this issue if @poojamat's suggestion works for you.

reberthkss commented 2 years ago

@reberthkss Feel free to close this issue if @poojamat's suggestion works for you.

Thank you for your reply @div5yesh . Can you take a look at this issue now? https://github.com/aws-amplify/amplify-android/issues/1642