Sunday, October 18, 2015

Android studio build issues- gradle proxy, file path size, etc

1. When running android studio on Windows, the gradle build may get an error of "No Resource found that matches ..." or "unable to open file ...". 

One possible reason of the error is due to the limitation of the maximal length of the file path. To fix the issue, move the project close to a root folder of the current drive, instead of staying in a deep nested subfolder on the current drive.


2. The android studio only build armv7 apk when running the app on emulator
In Build.gradle, locate productFlavors item and remove the "armv7" element


3. set proxy for gradle
create a text file with name of gradle.properties and put the file under the project's root folder with the content of:

systemProp.http.proxyHost=proxy.phl.sap.corp
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.phl.sap.corp
systemProp.https.proxyPort=8080


4. for the error of "Unable to execute dex: method ID not in [0, 0xffff]"

You need to enable multiDex with the below steps:
First, update android defaultConfig
android {
   defaultConfig {
      ...
      multiDexEnabled = true
   }
}

Then, add multiple dependency
dependencies {
  ...
  compile 'com.android.support:multidex:1.0.0'


5. for the out of memory GC error
Add the below options in Android block
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

No comments:

Post a Comment