-6

I have included this point, it does not help solve the problem!

 multiDexEnabled true

Build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.0'
    defaultConfig {
        applicationId "com.pokemongo.pokemon"
        minSdkVersion 16
        targetSdkVersion 24
    }
    buildTypes {
        release {
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:multidex:1.0.1'
}

Manifest:

<manifest package="com.pokemongo.pokemon"
xmlns:android="http://schemas.android.com/apk/res/android">
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
    android:minSdkVersion="18"
    android:targetSdkVersion="22" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/pikachu"
    android:name="android.support.multidex.MultiDexApplication"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light">
    <activity
        android:name=".CameraViewActivity"
        android:label="@string/title_activity_camera_view">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MapActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".CameraViewActivity" />
    </activity>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyD67YQ0A8XXPF5RvvtQIdJnc-gcqem5I9s" />

</application>

Error: enter image description here

Logs:

   Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2411Library
:app:prepareComAndroidSupportAppcompatV72411Library
:app:prepareComAndroidSupportMediarouterV72300Library
:app:prepareComAndroidSupportMultidex101Library
:app:prepareComAndroidSupportSupportV42411Library
:app:prepareComAndroidSupportSupportVectorDrawable2411Library
:app:prepareComGoogleAndroidGmsPlayServices940Library
:app:prepareComGoogleAndroidGmsPlayServicesAds940Library
:app:prepareComGoogleAndroidGmsPlayServicesAdsLite940Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics940Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl940Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing940Library
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite940Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth940Library
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase940Library
:app:prepareComGoogleAndroidGmsPlayServicesBase940Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement940Library
:app:prepareComGoogleAndroidGmsPlayServicesCast940Library
:app:prepareComGoogleAndroidGmsPlayServicesCastFramework940Library
:app:prepareComGoogleAndroidGmsPlayServicesClearcut940Library
:app:prepareComGoogleAndroidGmsPlayServicesContextmanager940Library
:app:prepareComGoogleAndroidGmsPlayServicesDrive940Library
:app:prepareComGoogleAndroidGmsPlayServicesFitness940Library
:app:prepareComGoogleAndroidGmsPlayServicesGames940Library
:app:prepareComGoogleAndroidGmsPlayServicesGass940Library
:app:prepareComGoogleAndroidGmsPlayServicesGcm940Library
:app:prepareComGoogleAndroidGmsPlayServicesIdentity940Library
:app:prepareComGoogleAndroidGmsPlayServicesIid940Library
:app:prepareComGoogleAndroidGmsPlayServicesLocation940Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps940Library
:app:prepareComGoogleAndroidGmsPlayServicesNearby940Library
:app:prepareComGoogleAndroidGmsPlayServicesPanorama940Library
:app:prepareComGoogleAndroidGmsPlayServicesPlaces940Library
:app:prepareComGoogleAndroidGmsPlayServicesPlus940Library
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet940Library
:app:prepareComGoogleAndroidGmsPlayServicesTagmanager940Library
:app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi940Library
:app:prepareComGoogleAndroidGmsPlayServicesTasks940Library
:app:prepareComGoogleAndroidGmsPlayServicesVision940Library
:app:prepareComGoogleAndroidGmsPlayServicesWallet940Library
:app:prepareComGoogleAndroidGmsPlayServicesWearable940Library
:app:prepareComGoogleFirebaseFirebaseAnalytics940Library
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl940Library
:app:prepareComGoogleFirebaseFirebaseAuth940Library
:app:prepareComGoogleFirebaseFirebaseAuthCommon940Library
:app:prepareComGoogleFirebaseFirebaseAuthModule940Library
:app:prepareComGoogleFirebaseFirebaseCommon940Library
:app:prepareComGoogleFirebaseFirebaseConfig940Library
:app:prepareComGoogleFirebaseFirebaseCrash940Library
:app:prepareComGoogleFirebaseFirebaseDatabase940Library
:app:prepareComGoogleFirebaseFirebaseDatabaseConnection940Library
:app:prepareComGoogleFirebaseFirebaseIid940Library
:app:prepareComGoogleFirebaseFirebaseMessaging940Library
:app:prepareComGoogleFirebaseFirebaseStorage940Library
:app:prepareComGoogleFirebaseFirebaseStorageCommon940Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: D:\Android Project\Virtual\POKEMON\Pokemon\app\src\main\java\com\pokemongo\pokemon\CameraViewActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:buildInfoDebugLoader
:app:transformClassesWithExtractJarsForDebug
:app:transformClassesWithInstantRunVerifierForDebug
:app:transformClassesWithJavaResourcesVerifierForDebug
:app:mergeDebugJniLibFolders
:app:transformNative_libsWithMergeJniLibsForDebug
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug
:app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE
:app:transformClassesWithInstantRunForDebug
:app:transformClasses_enhancedWithInstant+reloadDexForDebug UP-TO-DATE
:app:incrementalDebugTasks
:app:prePackageMarkerForDebug
:app:fastDeployDebugExtractor
:app:generateDebugInstantRunAppInfo
:app:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
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
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 1 mins 6.756 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
upward
  • 239
  • 1
  • 5
  • 14
  • Use `minifyEnabled` and set this true to make `Proguard` to effect minifying your code both in debug and release build. This might increase your build time a bit. – Reaz Murshed Aug 20 '16 at 05:31
  • Are you really using all the google play services? – Nongthonbam Tonthoi Aug 20 '16 at 05:31
  • Great question @NongthonbamTonthoi! Big problem, how do I specifically reduce all these unused methods? Got any ideas that worked for you? I have tried all manner of suggestions without any working... Thanks! – Wale Feb 09 '19 at 22:49

3 Answers3

2

Try this..

  defaultConfig {
    applicationId "com.pokemongo.pokemon"
    minSdkVersion 16
    targetSdkVersion 24

    multiDexEnabled true

    }

dexOptions should add..

dexOptions {
   //incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
 }

Also In Your AndroidManifest.xml add this lines android:name

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>

In your gradle..

  apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
    applicationId "com.pokemongo.pokemon"
    minSdkVersion 16
    targetSdkVersion 24
    multiDexEnabled true
}

   dexOptions {
  //incremental = true;
  preDexLibraries = false
  javaMaxHeapSize "4g"
  }
buildTypes {
    release {

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
 }
productFlavors {
 }
 }

 dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.1'
 }
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
0

You have tried for release while you are compiling a debug apk:

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

Try to include it in default one too:

multiDexEnabled true
sumandas
  • 555
  • 7
  • 20
  • I think you should read what you have written, you have not included multiDex line in default or no debug, if you understand gradle build flavors you should have picked it up as including in release doesn't add it to debug by default. Check the error image and from that it shows you are running debug. – sumandas Aug 20 '16 at 05:44
0

Please follow all steps listed below.

Enable multidex enabled true and allow support to your application as a multidex application.Few steps to be followed are:

defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 3
        versionName "1.0.1"
        **multiDexEnabled true**
    }

add this dependency to dependency list

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

extend your application level class with MultiDexApplication

write this method in your application class

protected void attachBaseContext(Context base)
    {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

update

dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g" //specify the heap size for the dex process
        preDexLibraries = false
    }
Jay Shah
  • 732
  • 4
  • 16