DexArchiveBuilderException when building Android application with Piwik SDK


(Nam Nguyen Hoai) #1

Hi all,

I’ve just included the Piwik SDK for Android into my mobile application according to this tutorial Getting started · matomo-org/piwik-sdk-android Wiki · GitHub

However, when I tried to build my application, I encountered this error:

Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process D:\AndroidProjects\HelloWorld\app\libs\PiwikAndroidSdk-e5a05d4.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/piwik/sdk/extra/DownloadTracker.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process D:\AndroidProjects\HelloWorld\app\libs\PiwikAndroidSdk-e5a05d4.jar

Anyone has ever experienced something similar? If yes, please guide me through.

This is the code in my application class:

package com.example.trungel.helloworld;


import android.os.StrictMode;

import org.piwik.sdk.TrackerConfig;
import org.piwik.sdk.extra.DownloadTracker;
import org.piwik.sdk.extra.PiwikApplication;
import org.piwik.sdk.extra.TrackHelper;

import timber.log.Timber;

public class MainApplication extends PiwikApplication {

    @Override
    public TrackerConfig onCreateTrackerConfig() {
        return TrackerConfig.createDefault("localhost", 3);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .build());
        initPiwik();
    }

    private void initPiwik(){

    }
}


#2

Set your project to source compatibility Java_1_8 (Java8), e.g. add:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

under the Android tag to your modules build.gradle file.

See:


(Nam Nguyen Hoai) #3

Thanks @darken. That worked for me!


(Max Cady) #4

solved my problem. thanks