2

I am using Android Studio,my project has 5 modules.

While running signed obfuscated apk I am getting the following error Unable to instantiate application com.....FTApplication: java.lang.ClassNotFoundException: Didn't find class "com....FTApplication" on path: DexPathList[[zip file "/data/app/app.apk"].

This is my configuration

DexGuard6.1.03 com.android.tools.build:gradle:1.0.0 - dependency Application extends from MultiDexApplication.

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.project.package">
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:name="com.project.package.FTApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />



        <activity
            android:name=".ui.activity.FTSplashActivity"
            android:label="@string/app_name"
            android:noHistory="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    </application>

</manifest>

top-level build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

module build.grade

apply plugin: 'com.android.application'
apply plugin: 'dexguard'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

buildscript {
    repositories {
        mavenCentral()
        flatDir { dirs '../../DexGuard6.1.03/lib' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath ':dexguard:'
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.project.package"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
    buildTypes {

        debug {
            proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
            proguardFile 'dexguard-project.txt'
        }
        release {
            proguardFile getDefaultDexGuardFile('dexguard-release.pro')
            proguardFile 'dexguard-project.txt'
        }

//        release {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
//        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':materialdialogs')
    compile project(':AndroidKit')
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile files('libs/disklrucache-2.0.1.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.jakewharton:disklrucache:2.0.2'
    compile files('libs/commons-httpclient-3.0.jar')
    compile files('libs/httpclientandroidlib-1.2.1.jar')
}
Raji A C
  • 2,261
  • 4
  • 26
  • 31
  • post your `manifest.xml` file and `gradle.build` – M D Aug 27 '15 at 06:33
  • After decompiling I found my application class file. – Raji A C Aug 27 '15 at 10:45
  • Issue was because of MultidexApplication.But still I could not solve the issue.I have to use multidex support since I am using some libraries and got method index out of bound exception – Raji A C Aug 30 '15 at 07:07
  • 1
    Raji, please try to turn on by adding -multidex in dexguard-project.txt, instead of setting multiDexEnabled = true in Gradle. That is using Dexguard's reflection call instead of Android's mulitdex support. Please see Dexguard's doc/index.html. It talked about the -multidex option. – John Sep 10 '15 at 20:32

1 Answers1

6

Thanks to @John for the comment.

Here is the solution for MultiDex with Dexguard:

1) Apply default MultiDex rules correctly. See my another post for correct options.

2) Modify build.gradle and dexguard-project.txt files.

build.gradle : Set multiDexEnabled true only for debug builds. Dexguard is going to handle it at release build.

defaultConfig {
    applicationId "com.sample"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"

    // NOTE 1 : Remove multiDexEnabled setting from here 
}

buildTypes {
    debug {
        // NOTE 2 : By default, debug builds don't need Dexguard. So set multiDexEnabled here.

        multiDexEnabled true
    }
    release {
        // NOTE 3 : Multidex is handled at dexguard-project.txt. So remove multiDexEnabled setting if exists.

        proguardFiles getDefaultDexGuardFile('dexguard-release.pro'),'dexguard-project.txt'
    }
}

dexguard-project.txt : Do not forget to add multidex option here!

-multidex 
Community
  • 1
  • 1
Devrim
  • 15,345
  • 4
  • 66
  • 74
  • @shadygoneinsane you should better contact with the Dexguard team. There may be updates at the sdk. – Devrim Nov 09 '18 at 05:31