Error:Execution failed for task ':app:dexDebug' using google play ads servies
Error:Execution failed for task ':app:dexDebug' using google play ads servies
我正在尝试将 admob 的 google 播放服务添加到我的 Android Studio 项目中,但是当我尝试 运行 该应用程序时,它一直失败并显示 1 error.So 我真的不知道怎么了?
this is Error:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable730Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: Cannot merge new index 65540 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)
at com.android.dx.merge.InstructionTransformer.access0(InstructionTransformer.java:26)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:842)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:813)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:785)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:682)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:542)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 35.156 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
===========================================================================
My Gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.keyboard"
minSdkVersion 11
targetSdkVersion 21
versionCode 2
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support.appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.3.0'
}
==============================================================
this is my Manifest File:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.keyboard"
android:versionCode="2"
android:versionName="1.1">
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21"
/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/roman"
android:theme="@style/keyboard_1_style"
android:label="@string/ime_name"
>
<activity
android:name="com.example.keyboard.help"
android:label="Example Keypad">
<intent-filter>
<action android:name=".Help"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im"
android:resource="@xml/method" />
</service>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"
>
</activity>
</application>
</manifest>
如果有人能给我一些关于我哪里出错的指示,我将不胜感激。
使用超过 65K 种方法构建应用程序:
您可以为此使用 multidex 支持库,启用 multidex
1) 将其包含在依赖项中:
dependencies {
...
compile 'com.android.support:multidex:1.0.0'
}
2) 在您的应用中启用它:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
....
multiDexEnabled true
}
3) 如果您的应用程序有应用程序 class,则重写 attachBaseContext 方法,如下所示:
包....;
...
导入 android.support.multidex.MultiDex;
public class MyApplication extends Application {
....
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
}
4) 如果您的应用程序没有应用程序 class,则在您的清单文件中将 android.support.multidex.MultiDexApplication 注册为您的应用程序。像这样:
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
它应该可以正常工作!
我正在尝试将 admob 的 google 播放服务添加到我的 Android Studio 项目中,但是当我尝试 运行 该应用程序时,它一直失败并显示 1 error.So 我真的不知道怎么了?
this is Error:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable730Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: Cannot merge new index 65540 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)
at com.android.dx.merge.InstructionTransformer.access0(InstructionTransformer.java:26)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:842)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:813)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:785)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:682)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:542)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 35.156 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
===========================================================================
My Gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.keyboard"
minSdkVersion 11
targetSdkVersion 21
versionCode 2
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support.appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.3.0'
}
==============================================================
this is my Manifest File:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.keyboard"
android:versionCode="2"
android:versionName="1.1">
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21"
/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/roman"
android:theme="@style/keyboard_1_style"
android:label="@string/ime_name"
>
<activity
android:name="com.example.keyboard.help"
android:label="Example Keypad">
<intent-filter>
<action android:name=".Help"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im"
android:resource="@xml/method" />
</service>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"
>
</activity>
</application>
</manifest>
如果有人能给我一些关于我哪里出错的指示,我将不胜感激。
使用超过 65K 种方法构建应用程序:
您可以为此使用 multidex 支持库,启用 multidex
1) 将其包含在依赖项中:
dependencies {
...
compile 'com.android.support:multidex:1.0.0'
}
2) 在您的应用中启用它:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
....
multiDexEnabled true
}
3) 如果您的应用程序有应用程序 class,则重写 attachBaseContext 方法,如下所示:
包....; ... 导入 android.support.multidex.MultiDex;
public class MyApplication extends Application {
....
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
}
4) 如果您的应用程序没有应用程序 class,则在您的清单文件中将 android.support.multidex.MultiDexApplication 注册为您的应用程序。像这样:
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
它应该可以正常工作!