Debug release build type without creating a signed APK

I have a project setup with two build types: debugand release.

In my application modules I have three different directories: debug, releaseand main.

What I want to do is check the code in the directory release, but the only way I can do this is to create a signed apk and upload it to the emulator this way. This means that I cannot debug it correctly.

When I change my module build option appto release, I get the following error in the "Edit Configuration" popup.

Error: apk for the option you selected (app-release-unsigned.apk_ is not signed. Specify the signature configuration for this option (release).

What I was hoping to do was extend the build option releaseusing one of the debugReleasein the build.gradlemodule file app, which would then inherit the code in the directory release, but I would be able to run it from the IDE.

I may be looking at it wrong, and I would be glad to hear any other methods.

Can I do what I'm trying to do? If this is not the best solution for this?

+4
source share
2 answers

After much research, I decided to continue my idea debugReleaseand it seems to work well.

app/src, debugRelease/java. , , apk .

. , , , , , - , .

build.gradle .

buildTypes {
    release {

    }

    debug {

    }

    debugRelease {
        signingConfig signingConfigs.debug
    }
}

sourceSets { 
    debugRelease {
        res.srcDirs = ['src/debug/res'] // this uses the debug res directory which contains a "debug" icon
    }

    release {
        java.srcDirs = ['src/debugRelease/java'] // this avoids copying across code from the debugRelease java directory
    }
}

, , , debugRelease.

+8

(, ) :

  • ProGuard
  • APK

app/build.gradle:

/* ADD THIS BLOCK, IF NOT ALREADY THERE */
lintOptions {
    // When you make a Release Build, the Android Lint tool will run to check many things.
    // It is set to abort the build on a single Lint error/warning. Disable this.
    abortOnError false
}

buildTypes {
    release {
        //minifyEnabled true   // <-- COMMENT OUT
        //proguardFiles ...    // <-- COMMENT OUT
        //shrinkResources true // <-- COMMENT OUT
        signingConfig signingConfigs.debug // <-- ADD THIS TO SIGN WITH YOUR DEBUG CERTIFICATE
        debuggable true     // <-- ADD THIS
        minifyEnabled false // <-- ADD THIS
    }
}

Android Studio ➔ "" Windows "" ➔ " " ➔ "TG41" , "", .

/ :

0

All Articles