Android: duplicate entry in build.gradle - android

I tried to run my Android application with Android Studio, and it showed an error saying the following message.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: com/mikepenz/iconics/core/BuildConfig.class
It seems like there's a duplicate library, so that's why it stops running. But I honestly don't know which I should fix with the build.gradle file. So I put my build.gradle file here, and somebody please help me out.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
//wrap with try and catch so the build is working even if the signing stuff is missing
try {
apply from: '../../../signing.gradle'
} catch (ex) {
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.marshall.opensurvey"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
def fileName = file.name.replace(".apk", "-v" + versionName + "-c" + versionCode + ".apk")
output.outputFile = new File(file.parentFile, fileName)
}
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-DEBUG"
try {
signingConfig signingConfigs.debug
} catch (ex) {
}
minifyEnabled false
}
release {
try {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} catch (ex) {
}
zipAlignEnabled true
minifyEnabled false
}
}
lintOptions {
abortOnError false
}
}
repositories() {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.squareup.picasso:picasso:2.3.2'
// Google Analytics Library
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
// Glide Library
compile 'com.github.bumptech.glide:glide:3.6.1'
// Material Drawer Library by Mike Penz
compile('com.mikepenz:materialdrawer:4.3.8#aar') {
transitive = true
}
// Android Iconics Library by Mike Penz
compile 'com.mikepenz:iconics-core:1.7.9#aar'
compile 'com.mikepenz:google-material-typeface:1.2.0.1#aar'
// Circle image view library
compile 'de.hdodenhof:circleimageview:2.0.0'
// AboutLibraries by Mike Penz
compile('com.mikepenz:aboutlibraries:5.2.5#aar') {
transitive = true
}
}

Your dependencies are conflicting.
duplicate entry: com/mikepenz/iconics/core/BuildConfig.class
This means two of your dependencies contain this class
// Android Iconics Library by Mike Penz
compile 'com.mikepenz:iconics-core:1.7.9#aar'
compile 'com.mikepenz:google-material-typeface:1.2.0.1#aar'
// AboutLibraries by Mike Penz
compile('com.mikepenz:aboutlibraries:5.2.5#aar') {
transitive = true // <- Why?
}
My guess is either the transitive shouldn't be specified or one of the com.mikepenz libs actually contains one of the other libs. For instance if iconics-core is contained in aboutlibraries then you should exclude it by
compile('com.mikepenz:aboutlibraries:5.2.5#aar') {
exclude module: 'com.mikepenz', name: 'iconics-core'
}
An easy way to track down dependency problems by running the gradle task dependencies via gradle dependencies. This shows a nice chart of libs depend on other libs

Related

Migrating to gradle 3.+ with libraries that compile different flavors

I have a very complex project with many libraries that are dependent on each other. I have gone through all of the documentation and videos but nothing is pointing me in the right direction to compile libraries based on flavors. I am confused with the project aspect. If anyone can point me in the right direction to update compile to implementation, that would be great. How do I directly replace configuration: to match the flavors?
Here in an example of two gradles.
vnfmdata
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
flavorDimensions flavor.default
productFlavors {
regular {}
no_meridian {}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
regularCompile project(':vncore')
regularCompile project(path: ':vnlocationservice', configuration: 'meridianDebug')
no_meridianCompile project(':vncore')
no_meridianCompile project(path: ':vnlocationservice', configuration: 'no_meridianDebug')
}
vnlocationservices
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
productFlavors {
no_meridian {}
meridian {}
}
buildTypes {
release {
//minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile deps.support.app_compat
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
no_meridianCompile project(':vncore')
meridianCompile project(':vncore')
meridianCompile project(':third:Sas-Android')
//Localytics
meridianCompile deps.support.compat_v26
meridianCompile deps.play.ads
meridianCompile deps.play.location
meridianCompile deps.localytics
///////////////////
meridianCompile 'com.arubanetworks.meridian:meridian:+#aar'
}
edit:
I found that adding a dependencies node into a flavor affected the other flavor. Instead it is better to use <flavor's name>Implementation.
As you stated, you probably went into the Migration Guide resolve matching errors.
vnfmdata
Here the changes are located on the flavors and how the dependencies changed:
android {
...
productFlavors {
regular {
// Forces regular's flavor to point on LocationService meridian's flavor
// because their flavors' name are different
matchingFallbacks = ["meridian"]
}
no_meridian {
// Will automatically point on LocationService no_meridian's flavor
// because they both have the same name
}
}
...
}
dependencies {
// We used the flavors' matching feature
// so gradle knows that if you select regular, you wants the meridian flavor on these 2 projects
implementation project (":vncore")
implementation project (":vnlocationservice")
}
vnlocationservices
Here we see how to declare a dependency which is only use by one flavor.
android {
...
productFlavors {
meridian {}
no_meridian {}
}
...
}
dependencies {
implementation project (":vncore")
meridianImplementation project(':third:Sas-Android')
//Localytics
meridianImplementation deps.support.compat_v26
meridianImplementation deps.play.ads
meridianImplementation deps.play.location
meridianImplementation deps.localytics
///////////////////
meridianImplementation 'com.arubanetworks.meridian:meridian:+#aar'
}
}

Android studio does not Generate Signed APK

The Problem is that , I'm getting error while generating Signed APK using Allatori Java Obfuscator. I tried different hacks like, Invalidate and Clear cache /Restart,by deleting build folder, rebuilding project, Strings , Even tried comparing package names ,Class Naming conventions,possible jars, deprecated methods or classes but Its of no use.!
Multi Dex is enabled as well.! and I tried every possible Solution but unable to generate signed APK.
apply plugin: 'com.android.application'
apply plugin: 'ensighten'
ext {
supportVersion = "25.3.1"
googleServices = "11.4.2"
}
android {
def version = "2.0.0"
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "removed"
minSdkVersion 15
targetSdkVersion 25
versionCode 20
versionName "${version}"
multiDexEnabled true
def today = new Date().format('yyyyMMdd_HHmmss').toString()
project.ext.set("archivesBaseName", "MyApplication_Android_Build_"+ today + "_Version " + version);
}
applicationVariants.all { variant ->
variant.javaCompile.doLast {
runAllatori(variant)
}
}
buildTypes {
debug {
buildConfigField "boolean", "LOG_ENABLED", "true"
buildConfigField "boolean", "SSL_ENABLED", "true"
buildConfigField "String", "SERVER_URL", "\"http:///\""
}
release {
buildConfigField "String", "SERVER_URL", "\"http://\""
buildConfigField "boolean", "LOG_ENABLED", "false"
buildConfigField "boolean", "SSL_ENABLED", "true"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
android {
aaptOptions {
cruncherEnabled = false
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://ensighten-mobile.bintray.com/maven" }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.1'
classpath "com.ensighten.plugin.android:ensighten:2.0.1"
}
}
apply plugin: 'io.fabric'
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/vividadmin/maven" }
maven { url "https://ensighten-mobile.bintray.com/maven" }
mavenCentral()
google()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':williamchart')
compile "com.android.support:appcompat-v7:${project.ext.supportVersion}"
compile "com.android.support:design:${project.ext.supportVersion}"
compile "com.android.support:percent:${project.ext.supportVersion}"
compile "com.android.support:cardview-v7:${project.ext.supportVersion}"
compile "com.android.support:recyclerview-v7:${project.ext.supportVersion}"
compile "com.android.support:animated-vector-drawable:${project.ext.supportVersion}"
compile "com.android.support:gridlayout-v7:${project.ext.supportVersion}"
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile "com.google.firebase:firebase-crash:${project.ext.googleServices}"
compile "com.google.firebase:firebase-core:${project.ext.googleServices}"
compile "com.google.firebase:firebase-invites:${project.ext.googleServices}"
compile "com.google.firebase:firebase-messaging:${project.ext.googleServices}"
compile "com.google.android.gms:play-services-analytics:${project.ext.googleServices}"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'net.danlew:android.joda:2.9.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.scottyab:aescrypt:0.0.1'
compile 'net.cachapa.expandablelayout:expandablelayout:2.9.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.ensighten.android:ensighten-core:2.4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
def runAllatori(variant) {
copy {
from "$projectDir/allatori.xml"
into "$buildDir/intermediates/classes/"
expand(classesRoot: variant.javaCompile.destinationDir,
androidJar: "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar",
classpathJars: variant.javaCompile.classpath.getAsPath(),
logFile: "allatori-log-${variant.name}.xml")
rename('allatori.xml', "allatori-${variant.name}.xml")
}
new File("${variant.javaCompile.destinationDir}-obfuscated").deleteDir()
javaexec {
main = 'com.allatori.Obfuscate'
classpath = files("$rootDir/allatori/allatori.jar")
args "$buildDir/intermediates/classes/allatori-${variant.name}.xml"
}
new File("${variant.javaCompile.destinationDir}").deleteDir()
new File("${variant.javaCompile.destinationDir}-obfuscated").renameTo(new File("${variant.javaCompile.destinationDir}"))
}
Error:
Error:Error converting bytecode to dex:
Cause: PARSE ERROR:
class name (com/pckg/pakistan/myapplication/R) does not match path (com/pckg/pakistan/myapplication/r.class)
...while parsing com/pckg/pakistan/myapplication/r.class
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
As per my knowledge you are using lot of libraries and using Allatori Java Obfuscator due to Allatori obfuscation your java code is not being properly converted into byte code and thats the reason you are unable to generate signed apk. Try a quick hack delete build files ,gradle files and invalidate and restart your project more than once
Hope this may help u :)
There is no Signing config in Gradle you have added, So first Create a Keystore (https://developer.android.com/studio/publish/app-signing.html)
and then add in the app level Gradle
signingConfigs {
release {
// For making app store release config below parameters
storeFile file('path to keystore')
storePassword "keystore password"
keyAlias "Alias_of_keystore"
keyPassword "Keystore Password"
}
}
after that in build types add
buildTypes {
// For app store release uncomment below and select release build flavor in Build Variants
release {
...
signingConfig signingConfigs.release
}}

Android Gradle 3 build failed

I have some troubles compiling my project with Gradle 3. When I update my project to use this version of Gradle, the gradle sync is okay, but as soon as I hit the run button, it gives me this:
Error:Execution failed for task
':app:compileBetaGoogleWebkitDebuggableReleaseJavaWithJavac'.
> java.lang.NoClassDefFoundError: com/fyber/annotations/FyberSDK
With older gradle (2.3.3) it works just perfect, but I need to update the project, for undisclosable, professional reason. What can go wrong between those two gradle versions, that one sees the FyberSDK and the other does not?
Here is my gradle script
apply plugin: 'com.android.application'
def mVersionCode = 16;
def mVersionName = "1.16"
android {
signingConfigs {
releaseSigning {
keyAlias 'redacted'
keyPassword 'redacted'
storeFile file('redacted')
storePassword 'redacted'
}
}
compileSdkVersion 23
defaultConfig {
applicationId "redacted"
minSdkVersion 19
targetSdkVersion 23
versionCode mVersionCode
versionName mVersionName
resValue "string", "app_version_name", mVersionName
resValue "string", "app_name", "redacted"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
debuggableRelease {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "server", "lib"
productFlavors {
pubGoogle {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "true")
}
betaGoogle {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "true")
}
pubAmazon {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "false")
}
betaAmazon {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "false")
}
/*xwalk {
dimension "lib"
}*/
webkit {
dimension "lib"
}
}
}
repositories {
mavenCentral()
maven {
name "Fyber's maven repo"
url "https://fyber.bintray.com/maven"
}
}
configurations {
provided
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.sponsorpay:sponsorpay-android-sdk:7.2.8'
compile 'com.fyber:fyber-sdk:8.17.0'
// Fyber Annotations
provided 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// Fyber mediation services
// UnityAds Mediation
compile 'com.fyber.mediation:unityads:2.1.1-r1#aar'
// ChartBoost Mediation
compile 'com.fyber.mediation:chartboost:6.6.3-r2#aar'
// Vungle Mediation
compile 'com.fyber.mediation:vungle:5.3.0-r1#aar'
// Vungle third-party dependencies
compile 'com.google.dagger:dagger:2.7'
compile 'javax.inject:javax.inject:1'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.android.gms:play-services-basement:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
// For AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.6.0#aar'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
//xwalkCompile 'org.xwalk:xwalk_core_library:23.53.589.4'
}
apply plugin: 'com.google.gms.google-services'
I also encountered this problem, eventually solved the problem.
you maybe use a annotations like this:
#FyberSDK
all you need to is find this annotations ,and change it's build.gradle file with this:
apply plugin: 'com.android.library'
android {
// ...
// add this code to enable annotationProcessor
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
dependencies {
// ...
// Fyber Annotations
compileOnly 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// ...
}
try this code ,and sync your project.hope is work fine, it's work fine for me.
if you want learn more for detail, you can read my blog here:
https://segmentfault.com/a/1190000012245056

Gradle not picking the libraries which are copied dynamically under lib folder

I have a requirement to load the different runtime libraries for a apk execution and unit test cases execution.
I am familiar with compile and testCompile scopes but problem is I don't want to load specific compile scope libraries while running the unit tests.
So I came up with some build.gradle like the below. I could able to copy the required jars/aars under the libs folder but these are not considered for class path.
Any thing wrong with this script?
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "example.com.myapplication"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
task getDynamicJars(type: Copy) {
delete fileTree("$projectDir/libs/")
if(project.gradle.startParameter.taskNames.contains("test")){
println("Loading Unit test dependencies");
from "$rootDir/runtimeLibs/test/"
into "$projectDir/libs/"
include '**/*.*'
}else{
println("Loading Execute dependencies from:"+"$projectDir/runtimeLibs/execution/"+" To:"+"$projectDir/libs/");
from "$rootDir/runtimeLibs/execution/"
into "$projectDir/libs/"
include '**/*.*'
}
}
dependencies {
println("Loading dependencies");
compile fileTree(dir: "libs", include: ['*.jar'])
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.0'
testCompile 'junit:junit:4.12'
}
project.afterEvaluate {
preBuild.dependsOn getDynamicJars
}
How do you like this solution:
def libsFolder
// ..
buildTypes {
release {
// ..
libsFolder = "${releaseLibsDir}"
}
debug {
// ..
libsFolder = "${debugLibsDir}"
}
}
// ..
dependencies {
compile fileTree(dir: "${libsFolder}", include: ['*.jar'])
}

Execution failed for task ':app:dexDebug' when i try compiling code

When I try compiling the code, I get the following error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''
finished with non-zero exit value 2
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.19.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.example"
minSdkVersion 14
targetSdkVersion 22
versionCode 20012
versionName '2.3.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
proguardFile '/My Workspace/FirstApp/proguard-android.txt'
debuggable false
multiDexEnabled true
}
debug {
minifyEnabled false
debuggable true
proguardFile '/My Workspace/FirstApp/proguard-android.txt'
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'LICENSE'
exclude 'license.txt'
}
productFlavors {
}
}
dependencies {
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/AF-Android-SDK-v2.3.1.17.jar')
compile 'com.squareup.okio:okio:1.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:22.2.1'
compile 'com.commonsware.cwac:anddown:0.2.+'
}
SOLUTION:
Used individual api libraries for google location services / gcm and removed the complete play service library. This reduced the dependable library methods and error got solved.
It's too general but, there are a couple of reasons why you get this error
1. Check dependencies{} in build.gradle. There must be duplicate libraries you're depending on.
More details : Check out my website
2. Enlarge heap size in build.gradle while compiling
android {
...
dexOptions{
incremental true
javaMaxHeapSize "4g"
}
}
I also faced the same problem when compiling my app but i refered this link
https://stackoverflow.com/a/22010135/5594089
it solved my issue.
if (BuildConfig.DEBUG) {
myView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Do something
}
});
}
after modifying it like this it will work
View.OnClickListener lClickListener = new View.OnClickListener() {
#Override
public void onClick(View v) {
// Do something
}
};
if (BuildConfig.DEBUG) {
myView.setOnClickListener(lClickListener);
}

Categories

Resources