Skip to content

add proguard rules for Android #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion wrappers/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ android {
}
buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.graphics.ImageFormat
import android.graphics.Point
import android.graphics.Rect
import android.os.Build
import androidx.annotation.Keep
import androidx.camera.core.ImageProxy
import java.lang.RuntimeException
import java.nio.ByteBuffer
Expand All @@ -44,6 +45,7 @@ public class BarcodeReader {
DATA_MATRIX, EAN_8, EAN_13, ITF, MAXICODE, PDF_417, QR_CODE, MICRO_QR_CODE, UPC_A, UPC_E
}

@Keep
public enum class ContentType {
TEXT, BINARY, MIXED, GS1, ISO15434, UNKNOWN_ECI
}
Expand All @@ -56,6 +58,7 @@ public class BarcodeReader {
val tryDownscale: Boolean = false
)

@Keep
public data class Position(
val topLeft: Point,
val topRight: Point,
Expand All @@ -64,6 +67,7 @@ public class BarcodeReader {
val orientation: Double
)

@Keep
public data class Result(
val format: Format = Format.NONE,
val bytes: ByteArray? = null,
Expand Down Expand Up @@ -127,13 +131,15 @@ public class BarcodeReader {
}
}

@Keep
// setting the format enum from inside the JNI code is a hassle -> use returned String instead
private external fun readYBuffer(
yBuffer: ByteBuffer, rowStride: Int, left: Int, top: Int, width: Int, height: Int, rotation: Int,
formats: String, tryHarder: Boolean, tryRotate: Boolean, tryInvert: Boolean, tryDownscale: Boolean,
result: Result,
): String?

@Keep
private external fun readBitmap(
bitmap: Bitmap, left: Int, top: Int, width: Int, height: Int, rotation: Int,
formats: String, tryHarder: Boolean, tryRotate: Boolean, tryInvert: Boolean, tryDownscale: Boolean,
Expand Down