2017-01-11 16 views
1

任何人都可以幫助我解決這個問題!它昨天工作,但今天當我今天早上再次運行我的應用程序時,它不起作用。.dex文件中方法引用的數量不能超過64K,multidexenabled不能正常工作,並且對於任務':app:clean'失敗

這是我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' 
} 

我曾嘗試使用此...

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

    // Enabling multidex support. 
    multiDexEnabled true 
} 

這...

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

但隨後出現新的錯誤...

找不到支持Android父母或祖先上下文方法登錄(查看):onclick屬性上的視圖類定義

這是我MainActivity login()方法...

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

而且即時運行沒有在機器人工作室工作......顯示錯誤:

執行失敗的任務「:應用程序:清潔」。無法刪除文件

當我啓用即時運行。請幫忙!

+0

你需要整個''com.google.android.gms:play-services:9.8.0''嗎?您只能包含您需要的播放服務的部分。 – Gudin

+0

[56k方法中的Android 64k方法限制錯誤可能的重複](http://stackoverflow.com/questions/26357228/android-64k-method-limit-error-on-56k-methods) –

+0

@Kevinrob你真的沒有'甚至讀到最後,是嗎?它與multiDex無關,正如您可以從最新的錯誤中看到的那樣。他修復了multiDex問題。 – Vucko

回答

0

問題是您的onClick方法不是public。我認爲這個錯誤與multiDex無關。簽名更改爲:

public void logIn(View view)... 
+0

在SO的人怎麼了?這是肯定的問題的答案,我得到一個減號?爲什麼?我甚至想要什麼呢? – Vucko

+0

昨天它使用非公開onClick方法,但今天它不工作! –

+0

@SayanMukherjee嘗試改變這個,讓我知道它是否修復它。 – Vucko

0

嘗試添加

android{ 
... 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 
0

我最近所面對你做了同樣的問題。如果應用程序包含太多的方法調用,則必須將其製作爲Multidex應用程序。不過,我不認爲你真的需要這樣做。

在你的app.gradle中,你有compile 'com.google.android.gms:play-services:9.8.0'這行,它基本上佔用了整個播放服務模塊,這是巨大的。我想你的應用程序需要永久構建。

因此,刪除一般的播放服務依賴關係(但如果您需要,請保留compile 'com.google.android.gms:play-services-appindexing:9.8.0')並添加或許您需要添加以下行apply plugin: 'com.google.gms.google-services'您的依賴列表結束後。

然後你就可以刪除所有multidex廢話:)

+0

完成剛剛提到的內容,但出現錯誤:錯誤:(40,0)找不到id爲'com.google.gms.google-services'的插件。 –

0

問題解決了,這是我做了什麼......

將它添加到的build.gradle

dexOptions { 
     javaMaxHeapSize "1g" 
    } 

和.. 。

multiDexEnabled true 

和改變的onClick方法公開...

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

我不知道實際上它的這些實際工作,我想起來!

謝謝你們的時間和幫助,非常感謝!

相關問題