Error reducing Google Play services’ impact on APK size error(8,0)

384 views
Skip to first unread message

Erik Perez

unread,
Apr 16, 2015, 6:47:12 AM4/16/15
to google-adm...@googlegroups.com
Hi, I'm working on an app and i'm trying to reduce google play services' impact on APK size according to this http://googleadsdeveloper.blogspot.ie/2015/01/reducing-google-play-services-impact-on.html,  and i get the following error when i try to synchronize the gradle proyect:

Error:(8, 0) Gradle DSL method not found: 'compile()'
Possible causes:
- The project 'MorphingTunnelFreeLauncher' may be using a version of Gradle that does not contain the method. Gradle         settings
- The build file may be missing a Gradle plugin.

The point to reduce the size is that many of these apps are <0.5 MB, but Admob library is >1MB. so if i set this library to this app, the size of this app will be doublesized. That's why i want to reduce this. The changes in the code looks like this:

- build.gradle in googleplayservices_lib

apply plugin: 'com.android.library'

android {
    compileSdkVersion 9
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 9
    }

    buildTypes {
        release {
            minifyEnabled true //changed
            shrinkResources true //changed
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/google-play-services.jar')
}


- build.gradle in the app itself:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        compile 'com.google.android.gms:play-services-ads:6.5.+'//changed

    }
}

allprojects {
    repositories {
        jcenter()
    }
}


So i don't know if i'm missing something here, i would be very thankful if somebody can help me with this problem.



Ram Parameswaran (Mobile SDK Team)

unread,
Apr 16, 2015, 2:20:02 PM4/16/15
to google-adm...@googlegroups.com
The compile 'com.google.android.gms:play-services-ads:6.5.+'//changed line should be in the app module level grade file and not the top level one.

- Ram

William Ferguson

unread,
Apr 17, 2015, 9:44:31 PM4/17/15
to google-adm...@googlegroups.com
So can also try using the GPS-.7.0.0 which splits each play services product into its own library.
And/Or using Proguard to trim away unusued classes.

William

Ram Parameswaran (Mobile SDK Team)

unread,
Apr 20, 2015, 2:42:02 PM4/20/15
to google-adm...@googlegroups.com
Setting the shrinkResources gradle property to true in the build.gradle file’s release configuration should leverage proguard to automatically exclude unused resources during the build process.

- Ram

Erik Perez

unread,
Apr 22, 2015, 6:07:40 AM4/22/15
to google-adm...@googlegroups.com
Well, i have changed the compile 'com.google.android.gms:play-services-ads:6.5.+'//changed line according to the suggestions given, as it shows in the first box(1) and it comes the error given in the second and third boxes ((2)(3)), So i don't know what the problem is, this time it tried to synchronize the gradle files with the project at least, but not successfully because of that error... still open to suggestions to solve this problem, either the error (8,0) given in the first post or the last one i got. 

Thanks a lot for the help given. 

(1)
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "tunnel.dimf"
        minSdkVersion 9
        targetSdkVersion 11
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_5
            targetCompatibility JavaVersion.VERSION_1_5
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':googleplayservices_lib')
    compile files('libs/appbrain-applift-sdk-v10.32.jar')
    compile 'com.google.android.gms:play-services-ads:6.5.+'//changed
}


(2)
Error:Execution failed for task ':googleplayservices_lib:proguardRelease'.
> java.io.FileNotFoundException: C:\Users\Erik\AndroidStudioProjects\MorphingTunnelFreeLauncher\googleplayservices_lib\proguard-rules.txt (Det går inte att hitta filen)

(3)
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':googleplayservices_lib:proguardRelease'.
> java.io.FileNotFoundException: C:\Users\Erik\AndroidStudioProjects\MorphingTunnelFreeLauncher\googleplayservices_lib\proguard-rules.txt (Det går inte att hitta filen)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED


William Ferguson

unread,
Apr 22, 2015, 11:37:23 AM4/22/15
to google-adm...@googlegroups.com
I don 't understand why you have 'compile project(':googleplayservices_lib')' listed as a dependency.
If you only need Admob then you already have that dependency listed. If you need other Play Services components then you should be listing then as library dependencies not as external project dependencies (if I'm reading the Gradle definition correctly).

William


--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/cczREwNEzP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 22, 2015, 2:27:45 PM4/22/15
to google-adm...@googlegroups.com
I think William's on the right track here. Is this an Eclipse project that's been rewired to work with gradle, or is it an Android Studio project?

Eclipse needs to have a library project included in order to take advantage of Google Play services (these library projects are often named something like "googleplayservices_lib"), while gradle can pull artifacts out of the Google repository automatically (which is what the compile 'com.google.android.gms:play-services-ads:6.5.+' does).

As William pointed out, it's likely that you only need the second of those two things, and removing the former might clear this up.

-Andrew
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Erik Perez

unread,
Apr 23, 2015, 9:30:04 AM4/23/15
to google-adm...@googlegroups.com
Well, i have changed the compile 'com.google.android.gms:play-services-ads:6.5.+'//changed line according to the suggestions given, as it shows in the first box(1) and it comes the error given in the second and third boxes ((2)(3)), So i don't know what the problem is, this time it tried to synchronize the gradle files with the project at least, but not successfully because of that error... still open to suggestions to solve this problem, either the error (8,0) given in the first post or the last one i got. 

Thanks a lot for the help given. 

(1)
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "tunnel.dimf"
        minSdkVersion 9
        targetSdkVersion 11
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_5
            targetCompatibility JavaVersion.VERSION_1_5
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':googleplayservices_lib')
    compile files('libs/appbrain-applift-sdk-v10.32.jar')
    compile 'com.google.android.gms:play-services-ads:6.5.+'//changed
}


(2)
Error:Execution failed for task ':googleplayservices_lib:proguardRelease'.
> java.io.FileNotFoundException: C:\Users\Erik\AndroidStudioProjects\MorphingTunnelFreeLauncher\googleplayservices_lib\proguard-rules.txt (Det går inte att hitta filen)

(3)
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':googleplayservices_lib:proguardRelease'.
> java.io.FileNotFoundException: C:\Users\Erik\AndroidStudioProjects\MorphingTunnelFreeLauncher\googleplayservices_lib\proguard-rules.txt (Det går inte att hitta filen)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED


____________________
 
Now i have changed my code like this  according to the given posts (1)(2) and still the same problem, so i don't know what the problem is now:

(1)
apply plugin: 'com.android.library'

android {
    compileSdkVersion 9
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 9
    }

    buildTypes {
        release {
           minifyEnabled true
           shrinkResources true
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/google-play-services.jar')
}


(2)
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "tunnel.dimf"
        minSdkVersion 9
        targetSdkVersion 11
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_5
            targetCompatibility JavaVersion.VERSION_1_5
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':googleplayservices_lib')
    compile files('libs/appbrain-applift-sdk-v10.32.jar')
}


error:

William Ferguson

unread,
Apr 23, 2015, 4:38:54 PM4/23/15
to google-adm...@googlegroups.com
You are still listing this dependency:
 compile project(':googleplayservices_lib')

I suspect it is the cause of your problems (as stated before).

William

 

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/cczREwNEzP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Erik Perez

unread,
Apr 27, 2015, 3:54:26 AM4/27/15
to google-adm...@googlegroups.com
Now i have erased this dependency

compile project(':googleplayservices_lib')

 but  i got a new problem at the android Manifest (1)(2), and the line that has the problem is this one (3) so i don't know what the problem is now. Thanks for the help.

(1)
AGPBI: {"kind":"ERROR","text":"No resource found that matches the given name (at \u0027value\u0027 with value \u0027@integer/google_play_services_version\u0027).","sourcePath":"C:\\Users\\Erik\\AndroidStudioProjects\\MorphingTunnelFreeLauncher\\morphingTunnel\\build\\intermediates\\manifests\\full\\debug\\AndroidManifest.xml","position":{"startLine":85,"startColumn":28,"startOffset":3222,"endColumn":65,"endOffset":3259},"original":""}


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':morphingTunnel:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Erik\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


(2)
Error:(85, 28) No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

(3)
 <application>
  ...
            <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
 </application>




William Ferguson

unread,
Apr 27, 2015, 6:35:28 AM4/27/15
to google-adm...@googlegroups.com
This is not an Admob question.

And a simple Google for google_play_services_version turns up 

Reply all
Reply to author
Forward
0 new messages