1

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'
}
halfer
  • 19,824
  • 17
  • 99
  • 186
driftking9987
  • 1,673
  • 1
  • 32
  • 63

1 Answers1

4

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.

Toris
  • 2,348
  • 13
  • 16
  • You are correct, removing `minifyEnabled` did the trick. On a sidenote, I intend to distribute the aar file of the library. So in that case, where should I run the `minifyEnabled` ? – driftking9987 Jan 21 '17 at 20:49
  • @driftking998 No. Don't run minify for aar. It removes all classes/methods as they are not used in the library itself. Also, keep class and method names. – Toris Jan 21 '17 at 21:15
  • NB: Use consumerProguardFiles to use ProGuard config file in libraries. http://stackoverflow.com/questions/26983248/proguard-ignores-config-file-of-library/27052696#27052696 – Toris Jan 21 '17 at 21:17
  • Saw the answer, but what should one do if they intend to distribute their SDK to developers which contains some critical/business logic component in it? How do I obfuscate the code in that case? – driftking9987 Jan 21 '17 at 21:21
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133727/discussion-between-toris-and-driftking9987). – Toris Jan 21 '17 at 21:24