1

Can anyone help me how to solve this! It was working yesterday, but today when I run my app again this morning, it is not working.

This is my build.gladle...

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    repositories {
        mavenCentral()
    }
    defaultConfig {
        applicationId "com.brandtechnosolutions.petbaazar"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}



dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:support-v4:25.1.0'
    compile `enter code here`'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    testCompile 'junit:junit:4.12'
}

I have tried to use this...

defaultConfig {
    ...
    minSdkVersion 15
    targetSdkVersion 23
    ...

    // Enabling multidex support.
    multiDexEnabled true
}

and this...

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

but then a new error comes...

Could not find method logIn(View) in a parent or ancestor Context for android:onClick attribute defined on view class

This is logIn() method in my MainActivity...

void logIn(View view) {                        //called when log in button pressed
    Intent intent = new Intent(MainActivity.this, LoginActivity.class);
    startActivity(intent);                 // start web activity
}

Also Instant Run is not working in android studio... shows error:

Execution failed for task ':app:clean'. Unable to delete file

when I enable the instant run. Please help!

Sayan Mukherjee
  • 352
  • 2
  • 21
  • Do you need whole `'com.google.android.gms:play-services:9.8.0'`? You can include only the parts of play-services you need. – JoKr Jan 11 '17 at 09:58
  • Possible duplicate of [Android 64k method limit error on 56k methods](http://stackoverflow.com/questions/26357228/android-64k-method-limit-error-on-56k-methods) – Kevin Robatel Jan 11 '17 at 10:01
  • @Kevinrob you truly didn't even read till the end, did you? It is not related to multiDex, as you can see from the newest error. He fixed the multiDex issue. – Vucko Jan 11 '17 at 10:10

4 Answers4

0

The problem is that your onClick method isn't public. I think the error is not related to multiDex anymore. Change the signature to:

public void logIn(View view)...
Vucko
  • 7,371
  • 2
  • 27
  • 45
0

Try to add

android{
...
    dexOptions {
        javaMaxHeapSize "4g"
   }
}
Prexx
  • 2,959
  • 5
  • 31
  • 48
0

I recently faced the same problem you did. If the app contains too many method calls, you must make it a Multidex Application. However, I don't think you really need to do that.

In your app.gradle you have the line compile 'com.google.android.gms:play-services:9.8.0' which basically takes the WHOLE play services module, which is huge. I guess your app takes forever to build as well.

So, delete the general play services dependency (but keep compile 'com.google.android.gms:play-services-appindexing:9.8.0' if you need it) and add perhaps you need to add the following line apply plugin: 'com.google.gms.google-services' AFTER the end of your dependency list.

Then you can remove all the multidex crap :)

Joakim
  • 3,224
  • 3
  • 29
  • 53
0

Problem solved, this is what I have done...

add it to build.gradle

 dexOptions {
        javaMaxHeapSize "1g"
    }

and...

multiDexEnabled true

and changing onClick method to public...

void logIn(View view) {                        //called when log in button pressed
    Intent intent = new Intent(MainActivity.this, LoginActivity.class);
    startActivity(intent);                 // start web activity
}

I don't know actually which of these actually work, I think together!

Thank you guys for your time and help, thanks a lot!

Sayan Mukherjee
  • 352
  • 2
  • 21