October 22, 2024
Chicago 12, Melborne City, USA
java

Unable to use instant app if i remove implementation ('app') from dependency of dynamic module?


I want to use One feature of my app as Instant app which needs below dependecy which is increasing the app size to 60MB.

implementation ('org.pytorch:pytorch_android_lite:1.13.1')
    implementation ('org.pytorch:pytorch_android_torchvision_lite:1.13.1')

Hence unable to Upload Instant app on playstore since for instant app to upload, size should be 15MB .

So i am trying to remove base module from dynamic module and check if size decreases and i can proceed with uploading

Unable to build project ,facing compile time error when removing "implementation project(":app")" this line from dynamic feature which i want to use as Instant app.

error :

plugins {
    id 'com.android.dynamic-feature'
    id 'org.jetbrains.kotlin.android'
}
android {
    namespace 'com.myapp.app.productscanner'
    compileSdk 34

    defaultConfig {
        minSdk 26
        minSdkVersion 26
        targetSdkVersion 34
        versionCode 561
        versionName "6.2.51"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    }

    buildTypes {
        release {
            minifyEnabled false
          
        }
        debug{

        }

        flavorDimensions "environment"

        productFlavors {
            production {
                dimension 'environment'
                applicationId "com.caratlane.app.productscanner"
              
            }
            prelive {
                dimension 'environment'
                applicationId "com.myapp.app.productscanner.prelive"
            }
            r2 {
                dimension 'environment'
              
                applicationId "myapp.app.productscanner.f2"
            }
        }
    }
    android {
        testOptions {
            unitTests.includeAndroidResources = true
            unitTests.returnDefaultValues = true

        }
    }

    dexOptions {
        javaMaxHeapSize "6g"
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
    }

    sourceSets {
        main {
            res.srcDirs = ['src/main/res', 'src/main/res/drawable/caratlane_push_notification_icon']
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

configurations.configureEach {
    resolutionStrategy {
        //force 'androidx.core:core:1.12.0'
        force 'androidx.core:core-ktx:1.12.0'
        force 'androidx.test.ext:junit:1.2.1'
        force 'androidx.test.espresso:espresso-core:3.6.1'
        force 'org.pytorch:pytorch_android_lite:1.13.1'
        force 'org.pytorch:pytorch_android_torchvision_lite:1.13.1'
        force 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
        force 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'

    }
}

dependencies {
    implementation project(":app")
  
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
  
    implementation 'junit:junit:4.13.2'
    implementation 'androidx.test.ext:junit:1.2.1'
    implementation 'androidx.test.espresso:espresso-core:3.6.1'

    //api 'com.google.mlkit:barcode-scanning:17.2.0'

    implementation ('org.pytorch:pytorch_android_lite:1.13.1')
    implementation ('org.pytorch:pytorch_android_torchvision_lite:1.13.1')

    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6"
} 



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video