Android-Studio: Fehler beim erstellen der APK

Vom einfachen Programm zum fertigen Debian-Paket, Fragen rund um Programmiersprachen, Scripting und Lizenzierung.
Antworten
inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 11.05.2017 17:16:35

Hallo,

wenn ich in Android-Studio "Run->Run App" klicke, wird die App auf das Gerät kopiert, gestartet und funktioniert tadellos. Wenn ich ein APK daraus erstellen will, unter "Build->Build APK" bekomme ich diesen Fehler:

Code: Alles auswählen

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.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Information:BUILD FAILED
Wer kann mir dabei helfen, den zu lösen? Die App ist schon fortgeschritten und es wäre doof das Projekt neu anlegen zu müssen.

inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 11.05.2017 20:10:09

Code: Alles auswählen

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForDebug'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
	at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
	at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
	at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
	at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
	at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
	at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
	at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
	at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:43)
	at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:40)
	at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
	at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
	at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:75)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
	at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
	at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
	... 78 more
Caused by: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
	at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:453)
	at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185)
	at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
	... 85 more
Caused by: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
	at com.android.builder.core.DexByteCodeConverter.dexInProcess(DexByteCodeConverter.java:180)
	at com.android.builder.core.DexByteCodeConverter.runDexer(DexByteCodeConverter.java:158)
	at com.android.builder.core.DexByteCodeConverter.convertByteCode(DexByteCodeConverter.java:143)
	at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1345)
	at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:443)
	... 88 more
Caused by: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
	at com.android.builder.core.DexByteCodeConverter.dexInProcess(DexByteCodeConverter.java:178)
	... 92 more
Caused by: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
	at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:488)
	at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:264)
	at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:497)
	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
	at com.android.dx.merge.DexMerger.merge(DexMerger.java:191)
	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:522)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:344)
	at com.android.dx.command.dexer.Main.run(Main.java:292)
	at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
	at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:174)


BUILD FAILED
Ein --info/--debug bring nicht mehr.
:?:

eggy
Beiträge: 3334
Registriert: 10.05.2008 11:23:50

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von eggy » 11.05.2017 20:39:19

Kein Plan ob das was bringt, aber da gibts gleich nen Haufen möglicher Gründe und Lösungsvorschläge:
http://stackoverflow.com/questions/3371 ... exfordebug
http://stackoverflow.com/questions/1520 ... ffff-65536
der zweite Link sieht erfolgsversprechender aus

inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 11.05.2017 20:49:58

Hm, noch blick ich das nicht.

Meine build.gradel Datei:

Code: Alles auswählen

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.inne.myapp"
        minSdkVersion 23
        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'
    })


    ### HERE ###
    compile 'com.android.support:appcompat-v7:25.3.1'
    ### HERE ###


    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'org.osmdroid:osmdroid-android:5.6.4'
    compile 'org.osmdroid:osmdroid-third-party:5.6.4'
    testCompile 'junit:junit:4.12'
}
Die mit ###HERE## markierte Zeile ist hervorgehoben und zeigt den Fehler/Meldung:

Code: Alles auswählen

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 24.0.0. Examples include com.android.support:animated-vector-drawable:25.3.1 and com.android.support:mediarouter-v7:24.0.0 less... (Strg+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
Hilft das?

eggy
Beiträge: 3334
Registriert: 10.05.2008 11:23:50

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von eggy » 11.05.2017 21:15:00

Code: Alles auswählen

Found versions 25.3.1, 24.0.0. 

Ich würd mal grep bemühen und schauen, ob das was offensichtliches findet.
Dann nochmal alles updaten, evtl ist ein Paket übersehn worden.
Und "a version lower than your targetSdkVersion" würde mich dazu verleiten zu schauen, ob ich meine target-Version Nebenwirkungsfrei runterdrehen kann, vielleicht reicht das ja schon.

inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 11.05.2017 22:28:47

Ein grep findet einiges.

Code: Alles auswählen

$ grep -r 24\\.0\\.0
app/build.gradle:    compile 'com.android.support:appcompat-v7:24.0.0'
app/build/outputs/logs/manifest-merger-debug-report.txt:MERGED from [com.android.support:mediarouter-v7:24.0.0] /home/inne/.android/build-cache/2b4e3b17652e474f12d7caa43498f176041b91bf/output/AndroidManifest.xml:22:5-20
app/build/outputs/logs/manifest-merger-debug-report.txt:MERGED from [com.android.support:palette-v7:24.0.0] /home/inne/.android/build-cache/4f9b641028f6ff1e90d76bd424a95af34bc51407/output/AndroidManifest.xml:22:5-23:19
app/build/outputs/logs/manifest-merger-debug-report.txt:MERGED from [com.android.support:mediarouter-v7:24.0.0] /home/inne/.android/build-cache/2b4e3b17652e474f12d7caa43498f176041b91bf/output/AndroidManifest.xml:20:5-43
app/build/outputs/logs/manifest-merger-debug-report.txt:MERGED from [com.android.support:palette-v7:24.0.0] /home/inne/.android/build-cache/4f9b641028f6ff1e90d76bd424a95af34bc51407/output/AndroidManifest.xml:20:5-43
app/app.iml:    <orderEntry type="library" exported="" name="palette-v7-24.0.0" level="project" />
app/app.iml:    <orderEntry type="library" exported="" name="mediarouter-v7-24.0.0" level="project" />
.idea/libraries/palette_v7_24_0_0.xml:  <library name="palette-v7-24.0.0">
.idea/libraries/palette_v7_24_0_0.xml:      <root url="jar://$USER_HOME$/Android/Sdk/extras/android/m2repository/com/android/support/palette-v7/24.0.0/palette-v7-24.0.0-sources.jar!/" />
.idea/libraries/mediarouter_v7_24_0_0.xml:  <library name="mediarouter-v7-24.0.0">
.idea/libraries/mediarouter_v7_24_0_0.xml:      <root url="jar://$USER_HOME$/.android/build-cache/2b4e3b17652e474f12d7caa43498f176041b91bf/output/jars/libs/internal_impl-24.0..jar!/" />
.idea/libraries/mediarouter_v7_24_0_0.xml:      <root url="jar://$USER_HOME$/Android/Sdk/extras/android/m2repository/com/android/support/mediarouter-v7/24.0.0/mediarouter-v7-24.0.0-sources.jar!/" />
.idea/workspace.xml:                <option name="description" value="Prepare com.android.support:palette-v7:24.0.0" />
.idea/workspace.xml:                <option name="description" value="Prepare com.android.support:mediarouter-v7:24.0.0" />
.idea/workspace.xml:                <option name="description" value="Prepare com.android.support:palette-v7:24.0.0" />
.idea/workspace.xml:                <option name="description" value="Prepare com.android.support:mediarouter-v7:24.0.0" />
Aber das manuell in den Dateien zu ändern bringt nichts, denn ein invalidated and rebuilt/restart setzt das alles wieder zurück.
Das Update läuft gerade.

Das targetSdkVersion kann ich bestimmt runter setzen.

inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 12.05.2017 00:10:49

Vielen Dank für deine Antworten @eggy.

Hangelt man sich bis zu diesem Link durch: https://developer.android.com/studio/bu ... tidex.html, dann findet man auch eine Lösung.

Code: Alles auswählen

BUILD SUCCESSFUL
Installation der app-debug.apk, funktioniert zumindest auf meinem Gerät auch schon einmal. In den Google-App-Store kopieren kostet allerdings einmal ~20-25 USD und ich habe noch nicht mal ein Kreditkarte dafür, um das zu bezahlen.

eggy
Beiträge: 3334
Registriert: 10.05.2008 11:23:50

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von eggy » 12.05.2017 08:32:57


inne
Beiträge: 3289
Registriert: 29.06.2013 17:32:10
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Android-Studio: Fehler beim erstellen der APK

Beitrag von inne » 12.05.2017 08:45:59

Ja, ging mir auch schon durch den Kopf.

Antworten