1

I created my first Android app 2 years ago in Eclipse and now I have some time to improve it. I do not have Eclipse installed anymore, so I decided to import the project into Android Studio.

But now I am running into several problems:

Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 14 declared in library [com.google.android.gms:play-services:10.2.0]

So in the build.gradle I changed it to 14. Then I got the next error

Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.

So therefor I changed the compileSdkVersion and the targetSdkVersion to 25 (correct me if it's wrong). And I changed

compile 'com.android.support:support-v4:20.0.0' 

into

compile 'com.android.support:support-v4:25.2.0' 

Now I could build my project. But when I tried to run my app, after more then 5 minutes(!) I got the next error :

Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

So then I added

multiDexEnabled true 

and

compile 'com.android.support:multidex:1.0.1' 

and

android:name="android.support.multidex.MultiDexApplication" 

to the manifest file.

My build.gradle now looks like this

apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "<<myApplicationId>>" minSdkVersion 14 targetSdkVersion 25 multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile 'com.android.support:support-v4:25.2.0' compile 'com.google.android.gms:play-services:+' compile files('libs/AppFireworks.jar') compile files('libs/fcvtgzwtzuliivdcu.jar') compile 'com.android.support:multidex:1.0.1' } 

But now I got the following pop-up and errors

Instant Run does not support deploying build variants with multidex enabled, to a target with API level 20 or below. To use Instant Run with a multidex enabled build variant, deploy to a target with API level 21 or higher.

Error:UNEXPECTED TOP-LEVEL ERROR:

Error:java.lang.OutOfMemoryError: GC overhead limit exceeded Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

What have I done wrong? Do I have to change the minSdkVersion to 21? I want to be able to run my app on Android 4.x. I could when I was developing in Eclipse. So far switching from Eclipse to Andriod Studio is going from bad to worse. :-(

1 Answer 1

1

you are compiling using compile 'com.google.android.gms:play-services:+'

play service is itself is a large library. You should not use + which implies all available version to compile

Rather use a specific version of play services or break down the library and use specific services like location,maps etc.

Also u can use dexOptions to increase ur memory usage during compilation

try changing your gradle file to:

 apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "<<myApplicationId>>" minSdkVersion 14 targetSdkVersion 25 multiDexEnabled true } dexOptions { incremental true javaMaxHeapSize "4g" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile 'com.android.support:support-v4:25.2.0' compile 'com.google.android.gms:play-services-maps:9.0.1' compile 'com.google.android.gms:play-services-plus:9.0.1' compile 'com.google.android.gms:play-services-location:9.0.1' compile 'com.google.android.gms:play-services-games:9.0.1' compile 'com.google.android.gms:play-services-gcm:9.0.1' compile files('libs/AppFireworks.jar') compile files('libs/fcvtgzwtzuliivdcu.jar') compile 'com.android.support:multidex:1.0.1' } 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks 007, I am getting there. When I used your gradle file, at least the app started. But building still took some time. So I read something about the play-services API's. I don't know why I need them. When I removed them all, I got an error about android:value="@integer/google_play_services_version" in my debug/AndroidManifest.xml. Do I need that, and if so, which API should I use to compile?
Nope, not that I'm aware of. I just tried a random API from your list. It compiles when I use the plus API and also when I use the gcm API (the others I just didn't try). So the most basic API will suffice, I think. But which one is the most basic API?
most used in-- maps and location apis. u can know more about the apis here developers.google.com/android

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.