driftking9987
driftking9987

Reputation: 1713

Package not found with android library module

I created two different Android Library Module in my existing project.

Now, when I am trying to run the app, it gives me an error saying that the said package doesn't exist in the project. This really baffles me as both the modules are right there and earlier when there was only one library module, it was working.

Moreover, it doesn't give any error while gradle building.

This one is app's gradle file:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.cl.lo"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile project(":ge")
    compile project(":in")
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'

}

This one is in gradle file.

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.google.android.gms:play-services-location:9.4.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}

And finally this one is ge gradle file :

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
}

Upvotes: 1

Views: 4796

Answers (1)

Toris
Toris

Reputation: 2386

Updated
Delete this line in ge build.gradle.

minifyEnabled true

Minify removes codes that are not used in the library, so app cannot find them.

NB: ProGuard settings should be put in app build.gradle and not in library ones.


Old answer

If it is Google Services related problem,
add this line at the bottom of your app's build.gradle.

apply plugin: 'com.google.gms.google-services'

The Google Services Gradle Plugin

Introduction
2 Add dependencies for basic libraries required for the services you have enabled. This step requires that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file so that no dependency collisions are introduced. You can see the result of this step by running ./gradlew :app:dependencies.

Upvotes: 4

Related Questions