Android studio plain java library proguard - java

Is it possible to have different build types for plain java libraries in Android Studio with gradle? My intention is to run proguard and minify the jar file size.
Java build.gradle
apply plugin: 'java'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
}
Android build.gradle
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "test.app"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
productFlavors {
buildWithSingleAlarmFlavour {
applicationId "test.app"
versionName ".1"
}
buildWithMultipleAlarmFlavour {
applicationId "test.app"
versionName "0.1"
}
}
}

Related

Why android studio 3, show me this error?

somebody can tell me, why Android Studio 3.0.1, show me this error when make app?
Execution failed for task ':joy-android-game-gdx:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
The next attach *my build gradle**
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.websmithing.gpstracker"
minSdkVersion 15
targetSdkVersion 25
versionCode 15
versionName "4.0.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.loopj.android:android-async-http:1.4.9'
}
the app compila when i delete this line:
compile 'com.android.support:appcompat-v7:25.0.0'
but the app after moment automatic close
Try
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.websmithing.gpstracker"
minSdkVersion 15
targetSdkVersion 25
versionCode 15
versionName "4.0.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:multidex:1.0.2'
}
Beside this, please review your dependency versions. They are not the latest versions and you might want to update them. Take care of the buildToolsVersion as well.

Unable to load javacv and googlecode in openCV Project

I am doing facerecognition in android using openCV but unable to load googlecode and javacv libraries.
Already having javacpp.jar and javacv.jar in
jniLibs
folder
Also used
compile 'com.googlecode.javacpp:javacpp:0.7'
in build.gradle.
My build.gradle is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.example.rsehdev.opencv"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary320')
compile 'com.googlecode.javacpp:javacpp:0.7'
//compile 'com.googlecode.javacv:javacv:0.7'
}

Android Error Regarding MultiDex

I'm getting the following error when I build my application in Android:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: oauth/signpost/http/HttpResponse.class
My build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.me.hey"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.semantics3:Sem3Java:1.2.2'
compile files('libs/Sem3Java-1.2.2-jar-with-dependencies.jar')
compile 'com.android.support:multidex:1.0.0'
}
Any ideas on what I might be doing wrong?

Coverage report says zero coverage on android with gradle

I've been unable to get code coverage to work on any of my android projects.
To simplify things I created a new project (selected empty activity).
Added a new utility class to the the project in src/main/java.
I then created a unit test for it in src/androidTest/java.
Updated the gradle file to enable coverage.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.michaelkrussel.coverageapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
jacoco {
version "0.7.1.201405082137"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
I ran the tests then using ./gradlew createDebugCoverageReport. The unit test shows that the test I created passed, but the coverage report reports zero coverage.
I assume I'm either missing something in the gradle file or not running the correct gradle task, but I cannot figure out what.
I'm using this configuration in my project and work fine!
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "br.com.acs.app"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
testApplicationId "br.com.acs.app.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
androidTestCompile 'junit:junit:4.11'
androidTestCompile('com.android.support.test:testing-support-lib:0.1') {
exclude group: 'junit'
}
}

cannot see Theme.Material or Android L's things

when i create values-v21 for android L' styles but when i cntrl+space for search there isn't any android L library.I checked android sdk manager,everything updated. and i'm using these library in build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "......."
minSdkVersion 13
targetSdkVersion 20
versionCode 3
versionName "1.1"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/commons-net-3.3-sources.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/commons-net-examples-3.3.jar')
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:3.1.+'
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.github.mrengineer13:snackbar:0.4.0'
}
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
you do not reference android L anywhere
your gradle should have these in it
compileSdkVersion 'android-L'
minSdkVersion 'L'
targetSdkVersion 'L'

Categories

Resources