Android Gradle dexcount-gradle-plugin - plugins

I read the documentation but I could not make it. I am using Android Studio 2.0 Stable version.
This is my project level build.gradle file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is app module level build.gradle file :
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
}
}
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
dexcount {
format = "list"
includeClasses = false
includeFieldCount = true
includeTotalMethodCount = false
orderByMethodCount = false
verbose = false
maxTreeDepth = Integer.MAX_VALUE
teamCityIntegration = false
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
}
}
ext {
supportLibVersion = '23.3.0'
googlePlayServicesVersion = '8.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
// eventbus
compile 'org.greenrobot:eventbus:3.0.0'
// rate me dialog
compile 'com.github.hotchemi:android-rate:0.5.6'
// apache commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}
this is giving error everytime :
Error:(11, 0) Dexcount plugin requires the Android plugin to be configured
what is the solution of this error ?

SOLUTION
I shifted the line of
"apply plugin: 'com.android.application'"
with
"apply plugin: 'com.getkeepsafe.dexcount'"
and it's worked

It is documented in Dex count's GitHub repo:
// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'
So as you said, just make sure that the Android plugin is before the Dex count plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'

Related

Unity 2020.2.6 Android build aptOptions noCompress property definition error

today I tried to build my game for Android with Unity 2020.2.6f1 and it gave the error below;
UnityException: Error mainTemplate.gradle file is using the old
aaptOptions noCompress property definition which does not include
types defined by unityStreamingAssets constant.
I disabled the Android Resolvers Patch gradle and manifest files it didn't work.
I tried to edit the gradle manually with;
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
whatever I do when building the game Unity overrides the gradle, I checked the pre-post build process scripts in the project but none of the ones I check changes the gradle' aaptOptions.
The plugins I have in the project are;
Facebook
GameAnalytics
Adjust
mainTemplate.gradle:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.installreferrer:installreferrer:1.0'
**DEPS**
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
multiDexEnabled true
minSdkVersion 19
targetSdkVersion 29
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
dexOptions {
preDexLibraries false
javaMaxHeapSize "4g"
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
}
**SIGN**
buildTypes {
debug {
jniDebuggable true
}
release {
minifyEnabled false
**SIGNCONFIG**
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_8
}
}
Thanks in advance.
you should modify like this in the mainTemplate.gradle file :
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
For me what worked was unchecking the "Custom Gradle Template" option for the build inside Player Settings > Publishing Settings.
Edit: Okay it turns out that I can't replicate that anymore and I am not really sure what kind of wizardry allowed it to happen...
On the other hand, I found what caused the issue for me.
The problem was caused by one plugin I was using, since I was importing an old version of it and for some reason it kept importing gradle documents and other Android related stuff, which were deprecated.
I fixed it by importing everything from the plugin's Unity Package except the Android folder, all the Editor's gradles and gradle related stuff (I didn't import the Editor folder at all) and the Plugins folder.
Let's try this option. Work like champ.
Open file maingradle in Android folder and remove line have string "Proguard" then save file
Go to project setting => untick mainGradle and tick again mainGradle, untick gradle properties template and tick it again. Go to Asset option in top => find option force resolve and rebuild again.

How to sign an Android application for publishing on playstore

when I try to publish my unity games on google developer, I always have this error:
Failed to import. You have imported an APK or Android App Bundle that
can be debugged. For security reasons, you must disable debugging
before the applicable APK or Android App Bundle can be published on
Google Play. Learn more about APKs or Android Bundle Bundle packages
for which the Debug feature has been enabled.
You have imported an APK or an Android App Bundle with a signature in debug mode. You must sign it in output version mode. Learn more about the signature.
I think there are something in maintemplate.gradle to change:
this is my mainTemplate:
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
release {
// Set minifyEnabled to true if you want to run ProGuard on your project
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debbugable false
**SIGNCONFIG**
signingConfig signingConfigs.firstapp
}
}
}
Just make sure your settings are like this -

Android studio Failed to resolve Facebook SDK

I have an issue in Android studio related to Facebook SDK and it's as below :
The build.gradle file (Project) looks like this :
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
url 'https://maven.google.com'
}
}
}
The build.gradle file (Module:app) looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 5
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
}
Repositories are well added but i can't figure out the issue.
Many thanks.

java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class

When I add facebook sdk dependencies to my android studio project, I have faced the issue :
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please help me to resolve this issue .
Here is my build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.1"
aaptOptions {
cruncherEnabled = false
}
defaultConfig {
applicationId "com.HN.xxx"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:support-v4:25'
compile ('com.facebook.android:facebook-android-sdk:4.+') {
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'

Android Log in with Twitter

I'm trying to integrate twitter login in my application, however not able to succeed yet.
https://dev.twitter.com/twitter-kit/android/twitter-login
In the above link it asks us to install Twitter Core library
dependencies {
compile('com.twitter.sdk.android:twitter-core:1.3.1#aar') {
transitive = true;
}
}
However, this library isn't being downloaded. I always throws an error
Failed to resolve: com.twitter.sdk.android:twitter-core:1.3.1
What should i do?
I have just solved your problem using the next instructions:
Inside your build.gradle (general):
your build script must be like this:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
2.Your build.gradle (app) must be like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile('com.twitter.sdk.android:twitter:1.5.1#aar') {
transitive = true
}
}
If you have any question, try to take a look this link:
https://github.com/twitter/twitter-kit-android
It works for me! Hope it helps!