Gradle sync fails with Dexguard plugin (Android Studio) - android

I am having a bit of trouble trying to integrate dexguard to my android/gradle project.
Dexguard: 5.5.32
gradle: 2.2.1
gradle-plugin: 1.3.0
buildToolsVersion: 23.0.1
I get the following error when I apply plugin: 'dexguard':
Error:Unable to load class 'com.android.builder.SdkParser'
EDIT:
Here is my app's gradle file:
buildscript {
repositories {
flatDir { dirs '/usr/local/DexGuard5.5.32/lib' }
jcenter()
}
dependencies {
classpath ':dexguard:'
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'dexguard' //This, when uncommented produces the error
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile files('libs/commons-collections4-4.0.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/jaxb2-maven-plugin:2.1.jar')
compile project(':sdk')
compile project(':zxing-lib')
}
android {
signingConfigs {
release {
//my signing config
}
}
compileSdkVersion 22
buildToolsVersion '23.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
resources.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
aidl.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
renderscript.srcDirs = ['src/main/java', 'src/main/native', 'src/test/java']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
//The following should be uncommented when dexuard works!!!
// debug {
// proguardFile plugin.getDefaultDexGuardFile('dexguard-debug.pro')
// proguardFile 'dexguard-project.txt'
// proguardFile 'dexguard-project-debug.txt'
// proguardFile 'proguard-project.txt'
// }
// release {
// proguardFile plugin.getDefaultDexGuardFile('dexguard-release.pro')
// proguardFile 'dexguard-project.txt'
// proguardFile 'dexguard-project-release.txt'
// proguardFile 'proguard-project.txt'
// }
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
defaultConfig {
targetSdkVersion 22
signingConfig signingConfigs.release
}
productFlavors {
app2 {
applicationId "some.app.id"
}
app {
applicationId "some.app.id2"
}
}
}
What are your thoughts ??

Your DexGuard plugin looks terribly outdated. The latest version, according to the GuardSquare website, is 7.0.22.
Upgrading is kind of mandatory, since version 7.x brought compatibility with gradle-plugin 1.3.x and build-tools 23.x.

Whats your Logcat Throws
Error:Unable to load class 'com.android.builder.SdkParser'
Cause
This problem is caused by android gradle plugin does not match for
gradle version.
Courtesy
Actually you are using old version DexGuard5.5.32 .That's why have problem . Use latest version of Dexguard & latest SDK and gradle plugins .
DexGuard 6.0 released
This section takes you through the steps of hardening your application
with DexGuard, from making sure the communication is secure, all the
way to encrypting strings and classes.
And upgrade your tools.build:gradle version for better approach .
dependencies {
classpath ':dexguard:'
classpath 'com.android.tools.build:gradle:1.4.0-beta2'
}
Regards
You can set compileSdkVersion 23 instead of 22 .
Try this way .I hope it will helps you .

Related

Package Signed APK with UBER sdk 0.5.1 return lots of error message

I got an issue with UBER SDK 0.5.1.
When I use android debug key, it is fine to create APK without any error message.
But when I create signed APK, there was lots of error message show up.
Contains "apache httpclient 4.0.1", retrofit ....
Here's the error message as below:
https://www.dropbox.com/s/7oce0kjodvp6rjl/uberError?dl=0
I'm using android studio to develop. Can somebody help me or give me some suggestion?
Here is my build script
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
configurations.all {
resolutionStrategy {
force 'com.android.support:design:23.4.0'
force 'com.android.support:support-v4:23.4.0'
}
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile(project(':libraries:SlidingMenuLib')) {
exclude module: 'support-v4';
}
compile "com.android.support:support-v4:24.0.0-beta1"
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services-maps:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.8.+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.uber.sdk:rides-android:0.5.2'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
android {
dexOptions {
javaMaxHeapSize "2048M"
preDexLibraries = false
}
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
buildTypes {
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
renderscriptOptimLevel 3
minifyEnabled true
pseudoLocalesEnabled false
zipAlignEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.FunNowconfig
}
debug {
debuggable true
jniDebuggable true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
production {
signingConfig signingConfigs.FunNowconfig
versionCode = 163
versionName '1.6.3'
}
stagin {
versionCode = 163
versionName '1.6.3Stg'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
defaultConfig {
buildConfigField "boolean", "AUTO_UPDATES", "true"
minSdkVersion 16
targetSdkVersion 20
multiDexEnabled true
buildConfigField "String", "CLIENT_ID", "\"${loadSecret("UBER_CLIENT_ID")}\""
//Add your client id to gradle.properties
buildConfigField "String", "REDIRECT_URI", "\"${loadSecret("UBER_REDIRECT_URI")}\""
//Add your redirect uri to gradle.properties
buildConfigField "String", "SERVER_TOKEN", "\"${loadSecret("UBER_SERVER_TOKEN")}\""
//Add your server token to gradle.properties
resValue "string", "googleApiKey", "\"${loadSecret("GOOGLE_API_KEY")}\""
resValue "string", "facebook_app_id", "\"${loadSecret("FACEBOOK_APP_ID")}\""
resValue "string", "gcm_sender_id", "\"${loadSecret("GOOGLE_GCM_SENDER_ID")}\""
}
}
}
/**
* Loads property from gradle.properties and ~/.gradle/gradle.properties
* Use to look up confidential information like keys that shoudln't be stored publicly
* #param name to lookup
* #return the value of the property or "MISSING"
*/
def loadSecret(String name) {
return hasProperty(name) ? getProperty(name) : "MISSING"
}
My top gradle as follow.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
repositories {
mavenCentral()
}
}
allprojects {
repositories {
mavenCentral()
}
}
It looks like a bug in the SDK using proguard.
Add this to your Proguard config as a short term workaround while we fix the SDK.
-dontwarn com.google.api.**

How to fix JDK mistake?

I have downloaded new Android Studio 2.1 and upgraded my openJDK to version 8.
But I have this issue :
What have I done wrong and what should I do?
Thanks!
added gradl
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:cardview-v7:23.3.0'
compile files('libs/svgandroid.jar')
compile 'com.android.support:design:23.3.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile files('libs/guava-16.0.1.jar')
compile 'com.google.code.gson:gson:2.6.1'
}
// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
'main', // main sample code; look here for the interesting stuff.
'common', // components that are reused by multiple samples
'template'] // boilerplate code that is generated by the sample template process
android {
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
repositories {
mavenCentral()
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
}
See the documentation: http://tools.android.com/tech-docs/configuration/osx-jdk
It involves setting a $STUDIO_JDK environment variable.

Zxing library integration gradle error in android studio

The gradle file content is below
apply plugin: 'com.android.library'
ext.artifactId = 'zxing-android-embedded'
dependencies {
compile project.zxingCore
// Optional dependency.
provided 'com.android.support:support-v4:22.0.0'
}
android {
resourcePrefix 'zxing_'
compileSdkVersion project.androidTargetSdk
buildToolsVersion project.androidBuildTools
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src-orig', 'src']
res.srcDirs = ['res-orig', 'res']
assets.srcDirs = ['assets']
}
}
// This is bad practice - we should fix the warnings instead.
lintOptions {
// Android warns about the he and id locale folders. he -> iw is already handled with a
// symlink. TODO: what about id?
disable 'LocaleFolder'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
It gives error Could not find property 'zxingCore' on project ':zxing-android-embedded'. for the compile project.zxingCore
Add the following dependency to your project build.gradle
dependencies {
compile 'com.google.zxing:core:3.2.1'
}
In my project it works fine.

Android Studio, Gradle and Card.IO

I am not sure how to get my project to build Card.IO with Gradle. My gradle file looks as follows:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "applicationId"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
My local.properties are as follows:
sdk.dir=/Applications/Android Studio.app/sdk
ndk.dir=/Applications/Android Studio.app/android-ndk-r10b
And my Project structure is as follows:
Now according to Card.IO (https://github.com/card-io/card.io-Android-SDK) all I need to do is copy the files into the correct directory, but this is not working.
I have also looked at the following posts:
Card.IO on Android with Gradle
https://github.com/paypal/PayPal-Android-SDK/issues/26 - this suggests some extra gradle methods but does no work
When I do this to my Gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "appId"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
java.srcDirs = ['src/main/java', 'src-gen/main/java']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
productFlavors {
x86 {
versionCode Integer.parseInt("6" + defaultConfig.versionCode)
ndk {
abiFilter "x86"
}
}
mips {
versionCode Integer.parseInt("4" + defaultConfig.versionCode)
ndk {
abiFilter "mips"
}
}
armv7 {
versionCode Integer.parseInt("2" + defaultConfig.versionCode)
ndk {
abiFilter "armeabi-v7a"
}
}
arm {
versionCode Integer.parseInt("1" + defaultConfig.versionCode)
ndk {
abiFilter "armeabi"
}
}
fat
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
Then Card.IO works, but I get the error: Crashlytics couldn't find the res folder specified in sourceSets.main.res, please make one. It picked: src/main/res.
I am very sure my problem is just a misunderstanding on Gradle - I am new to it. But there are no up to date complete answers that I can look at.
Somewhere along the line I managed to delete my Res folder using some gradle settings. Now when I put the gradle file back and the res files back it all compiles fine. Weird.
Thank goodness for Android Studio's view local history or I would have been set back a couple of days!

Cannot build Android project with Gradle (using Android Annotations)

I'm trying to use gradle to build my Android project wit Android Annotations but I still get errors. In my java classes AA is not found.
Also in gradle file I get some hints:
versionName "1.0" <- 'versionName' cannot be applied to '(java.lang.String)'
'main' in 'build' cannot be applied to '(groovy.lang.Closure)'
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'GENERATED_FOLDER']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
Below is my full gradle script:
buildscript {
repositories {
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:0.9.2'
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.1'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = '3.0.1'
dependencies {
// Android annotations
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
// ORMLite
compile 'com.j256.ormlite:ormlite-android:4.46'
// Google Guava
compile 'com.google.guava:guava:16.0.1'
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'pl.grzeslowski.weaselmoney'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'GENERATED_FOLDER']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
}
}
This is log from my console in Android Studio:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:weasel_moneyWeaselMoney:help
Welcome to Gradle 1.10.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 6.111 secs
Process finished with exit code 0
Dont put your AA configuration on your General build.gradle
put it in your app folder inside build.gradle, look # this example
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.2'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'com.example.app'
logLevel 'TRACE' //Use this to get AA log
logAppenderConsole 'true' //Use this to get AA log
}
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
debuggable true
}
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
dependencies {
//Libs
compile fileTree(dir: 'libs', include: ['*.jar'])
//Dependency
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M1' //If you're using REST
compile 'com.google.code.gson:gson:1.7.2'
compile 'org.codepond:wizardroid:1.3.0'
//Android Annotations
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}

Categories

Resources