I have the follow app bulild.gradle for my project. When I run the command gradle check no output is reported in the app/build/ folder. I basically used the same code for a previous project and it seemed to work just fine.
apply plugin: 'com.android.application'
apply plugin: "findbugs"
apply plugin: 'pmd'
apply plugin: "jdepend"
apply plugin: 'checkstyle'
findbugs {
ignoreFailures = false
effort = "max"
reportLevel = "low"
}
pmd {
ignoreFailures = true
}
jdepend{
ignoreFailures = true
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.enabled true
html.stylesheet resources.text.fromFile('config/xsl/checkstyle-custom.xsl')
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "dat255.refugeeevent"
minSdkVersion 15
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'
}
}
}
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.google.android.gms:play-services:9.6.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.code.gson:gson:2.7'
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile files ('libs/microsoft-translator-java-api-0.6.2-jar-with-dependencies.jar')
}
Check out gradle fury's quality plugin, works on android and non android projects https://github.com/gradle-fury/gradle-fury. We use it has something to force reports for the site plugin. It's largely based off of work of others with lots of tweaks to make it work correctly for both android and non android projects.
apply it
allprojects {
apply from: "https://raw.githubusercontent.com/gradle-fury/gradle-fury/master/gradle/quality.gradle"
}
and then you'll need the contents from here: https://github.com/gradle-fury/gradle-fury/tree/master/config cloned into your repo. Just the config folder, the rest of the stuff isn't needed.
finally, either call any gradle tasks that requires check. So any one of the following should do the trick
gradlew build
gradlew check
gradlew install (if you're running the maven-support stuff from fury)
Add below configuration to you gradle.build file. Basically it does not find android repository and related details in your configuration.
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Related
I trying to assemble my project, but I only get an error:
Error:Execution failed for task ':basetools:processDebugAndroidTestResources'.
> No slave process to process jobs, aborting
I didn't change anything in my gradle files but abruptly got this error.
I already tried invalidate cahces and restart, rebuild
What should I do to fix it?
This is my project's build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
apply from: 'scripts/dependencies.gradle'
apply from: 'scripts/testDependencies.gradle'
repositories {
google()
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://maven.google.com"
}
maven { url 'https://jitpack.io' }
}
dependencies {
classpath plugin.android
classpath plugin.fabric
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://maven.google.com"
}
maven { url 'https://jitpack.io' }
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000" // or whatever number you want
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is a build.project of app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
def mainKeystore = file("../main.keystore")
//def debugKeystore = file("../debug.keystore")
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.ilyinp.valutetracker"
minSdkVersion 19
targetSdkVersion 26
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
release {
storeFile mainKeystore
keyAlias "valutetracker"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
incremental = false
}
}
kapt {
generateStubs = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile project(base.baseTools)
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
kapt "com.android.databinding:compiler:3.0.0"
compile dep.dagger.lib
kapt dep.dagger.apt
compile dep.moxy.lib
compile dep.moxy.appCompat
kapt dep.moxy.apt
compile(dep.crashlytics) {
transitive = true
}
compile 'com.google.android.gms:play-services-ads:11.6.0'
}
apply plugin: 'com.google.gms.google-services'
And finally, build.gradle of module basetools
apply plugin: 'com.android.library'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
kapt {
generateStubs = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile dep.support.multiDex
// compile dep.support.appCompat
compile dep.support.cardView
compile dep.support.recyclerView
compile dep.support.design
compile dep.support.constraintLayout
compile dep.glide.lib
compile dep.glide.transformations
compile dep.rxjava.lib
compile dep.rxjava.android
compile dep.rxjava.permissions
compile dep.rxjava.binding
compile dep.rxjava.bindingCompat
compile dep.retrofit.lib
compile dep.retrofit.converter.gson
compile dep.retrofit.adapter.rxjava
compile dep.okhttp.lib
compile dep.okhttp.interceptor.logging
compile dep.dagger.lib
kapt dep.dagger.apt
compile dep.timber
compile dep.moxy.lib
compile dep.moxy.appCompat
kapt dep.moxy.apt
compile dep.materialDialogs
compile dep.parceler.lib
kapt dep.parceler.apt
compile dep.cicerone
compile(dep.fastadapter) {
transitive = true
}
compile(dep.fastadapterCommons)
compile(dep.fastadapterExtensions)
compile(dep.materialize) {
transitive = true
}
compile(dep.crashlytics) {
transitive = true
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
kapt "com.android.databinding:compiler:3.0.0"
}
repositories {
mavenCentral()
}
Go to Android Studio, click "File" and click "Invalidate Caches / Restart...". This will work.
change
minifyEnabled true
to
minifyEnabled false
if above changes does not work then try this as well
shrinkResources true
to
shrinkResources false
Restarting Android Studio wasn't enough to resolve this error for me: I also had to kill an aapt2 process which had been left behind.
Same issue. Invalidate caches and restart done the job for me.
You can delete build folder in project and modules. After Invalidate Caches and Restart , it work for me!
You can try it
'Clean Project'、'rebuild project' doesn't work.I solved this problem by invalidate and restart
Delete build folder manually (project's build and modules' build)
Delete old .impl file
Restart Android Studio
I was going through some RnD and applied above nothing worked, rather that made my project to crash completely and re do.
I was not shutting down and restart the system everyday.
When I got the next time I simply didn't do anything but restarted the system. It worked fine!!..
Guys , keep in mind : Invalidate Caches and Restart will make you loose complete history of code changes.
shrinkResources to false /
minifyEnabled to false will cost you few kbs of apk size
I am creating a blank project in which I add mapbox navigation package compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3' in the gradle file. It shows error in appcompat file like this:-
Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0
eventhough I use different version of Appcompat file. Before adding navigation package, everything was fine. Can someone please help me to find out this weird error.
Here is my app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.aadhilahmed.test7"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:25.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Specify:
compile ('com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3') {
transitive = false;
}
Try this.Starting from version 26 of support libraries make sure that the repositories section includes a maven section
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For Gradle build tools plugin version 3.0.0
allprojects {
repositories {
jcenter()
google()
}
}
I created an Android library named "core" that use the Logger library (https://github.com/orhanobut/logger).
Here its build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.orhanobut:logger:1.15'
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
Then I build a .aar of core library.
I add this library as a dependency into my application, by putting the .aarcore files in the libs folder.
That's the build.gradle of my application :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.package.test"
minSdkVersion 16
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'com.mypackage:core:1.0#aar'
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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:multidex:1.0.1'
}
As you can see I have multidex activated.
It compile just fine but at runtime, at the first call to Logger I get an exception:
stack=java.lang.NoClassDefFoundError: Failed resolution of: Lcom/orhanobut/logger/Logger;
Even if I set transitive = true
compile (com.mypackage:core:1.0#aar) {
transitive=true
}
it doesn't work.
Thank you !
I had to do a couple of things in concert to get it to work.
1) In your library project
Add the following to your project-level gradle file:
buildscript {
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
Be sure to use the right version of the plugin for your gradle version, check here.
Add the following to your module-level gradle file:
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.YourPackage'// Doesn't have to be github, just an example
Also in this file, make sure your dependencies (the ones you want to be transitive) use api instead of implementation if you are using Gradle 3.4+. If you are using a version of Gradle <3.4, compile is the way to go. Example:
dependencies {
api 'com.google.android.gms:play-services-location:15.0.1'
}
2) In your app project (which uses the library)
Add the following to your module-level gradle file:
dependencies {
implementation('com.github.YourPackage:yourRepo:version#aar') {
transitive=true
}
}
Add the following to you project-level gradle file (but this will depend on where your library is served from, for me it's jitpack):
allprojects {
repositories {
...
maven {
url 'https://jitpack.io'
credentials { username 'yourAuthKey' }// Only for private repositories
}
}
}
Note: You shouldn't add the auth key as a string in build.gradle, put it in a property in your gradle.properties file.
Note 2: JitPack allows you to use for example development-SNAPSHOT as a version number for a gradle dependency. Android Studio caches these dependencies and will not re-download it when you push to your development branch. To overcome this, use commit hashes as version numbers during development or clear (delete) the cache files, located on Windows at ~/.gradle/caches/modules-2/metadata-x.xx/descriptors/com.github.YourPackage/yourRepo. (Needles to say, I learned this the hard way).
:app:mergeDebugAssets
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK kotlin/internal/internal.kotlin_builtins
File1: /Users/KD/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.0.4/172b43fbc03b521fed141484b212d6725fa671a9/kotlin-compiler-embeddable-1.0.4.jar
File2: /Users/KD/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-runtime/1.0.4/8e25da5e31669f5acf514bdd99b94ff5c7003b3b/kotlin-runtime-1.0.4.jar
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.app2par.ctime"
minSdkVersion 16
// minSdkVersion 21
// targetSdkVersion 23
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled false
// multiDexEnabled true
}
dexOptions {
preDexLibraries true
javaMaxHeapSize "2g" // Use gig increments depending on needs
incremental true
}
buildTypes {
debug {
minifyEnabled false
// testCoverageEnabled true
// ext.betaDistributionReleaseNotes = getCrashlyticsBetaMessage()
// ext.betaDistributionGroupAliases = 'team'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
// dataBinding {
// enabled = true
// https://code.google.com/p/android/issues/detail?id=187443&q=attachments%3D0&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
// }
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':firebasesync')
compile project(':liboid')
compile project(':cloudtimemodel')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude group: 'com.android.support'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
exclude group: 'com.android.support'
}
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
// transitive = true;
// }
// compile 'com.google.android.gms:play-services:5.0.89'
// compile 'com.google.android.gms:play-services:7.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// compile 'com.firebase:firebase-client-android:2.0.3.+'
// compile 'com.google.android.gms:play-services-safetynet:8.3.0'
// compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-plus:7.0.0' // play-services-plus:7.0.0 : office-mover
// compile 'com.google.android.gms:play-services-auth:8.3.0' // play-services-auth:8.3.0 : ShoppingList++
// compile 'com.google.android.gms:play-services-identity:7.0.0'
}
buildscript {
// ext.kotlin_version = '1.0.0-rc-1036'
ext.kotlin_version = '1.0.4'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'org.ajoberstar:grgit:1.1.0'
// classpath 'io.fabric.tools:gradle:1.+'
// classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.5.0-x'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
How to fix or diagnose this?
You should remove compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" from your dependencies section and move it to buildscript { dependencies { ... } }.
You did put compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" in the wrong build.gradle file
You may use kotlin plugin's build-in converters to deal with this. According to Kotlin Docs:
Configuring Kotlin in the project
When adding a new Kotlin file, IntelliJ IDEA (and Android Studio)
automatically prompts us as to whether we'd like to configure the
Kotlin runtime for the project. However, currently, converting
existing Java file does not prompt this action. Therefore we have to
invoke it manually (via Find Action):
We are then prompted for the version of Kotlin. Choose the latest
available from the list of installed versions.
After we configure Kotlin, build.gradle file for the application
should be updated. Now we can see that apply plugin: 'kotlin-android'
and the dependencies were added.
(For more details how to set up gradle for your project, please check
Using Gradle)
The last thing to do is to sync the project. We can press Sync Now
in a prompt or invoke an action Sync Project with Gradle Files.
From: https://kotlinlang.org/docs/tutorials/kotlin-android.html
Check link above for more information.
Hope it will help.
you need to apply only one plugin, in your case apply plugin: 'kotlin-android-extensions' and only compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" this dependency. it worked for me
I installed Fabric in my project using Android Studio's Fabric plugin. It prevented a lot of other bugs I was getting, but I still get java.exe finishing poorly. I tried out all the other links on java.exe exiting with value 2, and nothing helped or was applicable.
Here's my build.gradle
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'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.youtubemaster"
minSdkVersion 11
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.google.code.gson:gson:2.3.1'
compile ('com.facebook.android:facebook-android-sdk:4.0.0')
{
exclude group: 'com.google.android', module: 'support-v4'
}
compile files('libs/picasso-2.5.2.jar')
compile files('libs/retrofit-1.9.0.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile('com.twitter.sdk.android:twitter:1.4.0#aar') {
transitive = true;
}
}
Since you are using Twitter sdk, which already contains Retrofit and gson,
you will have to remove the following from your gradle
compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/retrofit-1.9.0.jar')
I too had the problem.
I ran into the same problem now and fixed it by enabling multidex.
https://developer.android.com/tools/building/multidex.html#mdex-gradle
Add this into your build.gradle:
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
/* Enabling multidex*/
compile 'com.android.support:multidex:1.0.0'
}
Add this into your manifest:
<!--Supporting multidex-->
<application
android:name="android.support.multidex.MultiDexApplication" >
You will need multidex when you have exceeded your method count of 65536 which is actually quite easy to do if you add different libraries onto your build.gradle.