Execution failed for task ':app:compileDebugKotlin' - android

I recently updated my kotlin and kotlin extensions plugin and while building I am getting the following error. I tried clean build or sync project with gradle but nothing works
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
The build.gradle is as follows
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
buildscript {
ext.kotlin_version = '1.0.0-beta-1038'
ext.anko_version = '0.7.2'
ext.android_support_version = '23.0.1'
ext.android_extensions_version = '1.0.0-beta-1038'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.xxxxxxxxxx.app"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'build/generated/src/main/debug'
release.java.srcDirs += 'build/generated/src/main/release'
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
jcenter()
mavenCentral()
jcenter { url "https://jitpack.io" }
}
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'io.realm:realm-android:0.83.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
compile 'com.braintreepayments.api:braintree:1.+'
compile('com.mikepenz:materialdrawer:4.4.1#aar') {
transitive = true
}
compile 'com.mikepenz:google-material-typeface:1.2.0.1#aar'
compile project(':temperature')
compile project(':heart')
compile project(':lungs')
compile "com.android.support:cardview-v7:$android_support_version"
compile 'com.github.wendykierp:JTransforms:3.1'
compile 'fuel:fuel:0.57'
compile "org.jetbrains.anko:anko-sdk15:$anko_version"
compile "org.jetbrains.anko:anko-support-v4:$anko_version"
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'com.google.android.gms:play-services:8.1.0'
compile "com.android.support:recyclerview-v7:$android_support_version"
compile "com.android.support:appcompat-v7:$android_support_version"
compile "com.android.support:support-v4:$android_support_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
can someone point out what is the issue with this?
Thanks

I solved this problem by building the project in terminal then run app in intellij(or android studio).
gradle clean build -> run app in ide

For me, the solution was to open the Gradle Console window in Android Studio and run the build with a StackTrace.
Then, reading through that, I realised that the new of doing some things in Kotlin required my code to change, but a normal Gradle build didn't catch those problems.
It was things like views being cast to TextView or whatever the case might be, that was not relevant anymore, and had to be changed to the findVieById format. e.g.:
val textView = snackbarView.findViewById(R.id.snackbar_text) as TextView
had to be changed to
val textView = snackbarView.findViewById<TextView>(R.id.snackbar_text)

In the case of a project I was recently working on, I was getting the same kind of error, which was caused by a call to a static method that no longer existed.
MessageService.java
public class MessageService extends FirebaseMessagingService {
/*
This method was commented out
private static String GetReviewTopic(String userId)
{
return "/topics/"+userId+"/review";
}
*/
}
AppActivity.java
#Override
public void onCreate() {
...
/*
No complication error was caused despite the
method not being defined.
*/
MessageService.GetReviewTopic(currentUser);
...
}
Unfortunately Android Studio wasn't reporting a "syntax error" for the missing static method, nor were there any meaningful complication errors that helped me track the issue down.
Hope this answer is able to save someone a few hours of troubleshooting!

Related

Error:Could not find com.google.android.gms:play-services:10.2.0

I have imported a procject it was with admob but now cannot compile my project beacuse of this error..
I was trying to add in all my gradle dependecies but same error happens
Error:Could not find com.google.android.gms:play-services:10.2.0.
Searched in the following locations:
file:/D:/AndroidStudio/AndroidStudio/gradle/m2repository/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.pom
file:/D:/AndroidStudio/AndroidStudio/gradle/m2repository/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.jar
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.pom
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/10.2.0/play-services-10.2.0.jar
Required by:
project :android > project :BaseGameUtils
and this is my build.gradle (BaseGamesUtils)
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:10.2.0'
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'
}
I also removed from here and added to build.gradle (Module: android) but same error same on build.gradle( Project: MyProject ) any help will be very appriciated, I'm spendin 3 days now for this error..
As I see:
file:/D:/AndroidStudio/AndroidStudio/gradle/m2repository/com/google/android/gms/play-services/
don't even exist.. and project is looking there...
Everything is updated like sdk and gradle to 3.3 but nothing helps...
I figured out thanks to Abhishek Aryan question and one other question found in stack overflow and changed the location where the maven was looking for repositories..
I added the folowing two lines on repositories:
maven { url "D:/AndroidStudio/AndroidStudioSDK/sdk/extras/android/m2repository" }
maven { url "D:/AndroidStudio/AndroidStudioSDK/sdk/extras/google/m2repository" }
so my total is:
repositories {
maven { url "D:/AndroidStudio/AndroidStudioSDK/sdk/extras/android/m2repository" }
maven { url "D:/AndroidStudio/AndroidStudioSDK/sdk/extras/google/m2repository" }
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://oss.sonatype.org/content/repositories/releases/' }
Finially after a week, xD and Thank you guys for your time and help :)

cannot install two flavors of an app with Android Annotations

I have an app using Android Annotations and everything is working fine except one thing - you cannot install both flavors on the same device despite the fact that they have different applicationId.
Researching this I came across some problems (that other people had) with annotation processing and flavors, and as I recall this was an issue also here, but we've manage to add following snippet and everything worked.
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
Until the other day we've didn't notice, that we couldn't install two flavors at once on one device. I've tried changing the gradle but every time I've ended up with the same problem or breaking the gradle script.
As I've mentioned, I've tried all things that I could think of and the online search didn't turn up anything useful, so if anybody have any idea I'll appreciate it.
Following there are my build.gradle scripts.
Top level:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:2.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App module level:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'
android {
signingConfigs {
config {
keyAlias 'release'
keyPassword 'keyPassword'
storeFile file('../storeFile.jks')
storePassword 'storePassword'
}
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "some.awsome.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
signingConfig signingConfigs.config
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
productFlavors {
COGNICARE_personal {
applicationId "some.awsome.app.free"
}
COGNICARE_full {
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven { url "https://jitpack.io" }
mavenCentral()
}
def android_annotations_version = '3.3.2'
def google_libs_version = '23.3.0'
//some lib versions omitted
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//some aar lib omitted
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$google_libs_version"
apt "org.androidannotations:androidannotations:$android_annotations_version"
compile "org.androidannotations:androidannotations-api:$android_annotations_version"
//some libs omitted
compile 'com.android.support:multidex:1.0.0'
//some libs omitted
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
Thanks in advance for any suggestion. Kudos!
OK, so thanks to #ligi pointing me to the right track.
We have a similar project with a very similar setup and the main difference are the Android Annotation used in one of them, an that has mislead me.
The bottom line is that I've had a provider in the manifest that I wasn't aware of, and the authority conflict did occur at that point.
Thanks for your time. Kudos.

Android app is only running when compiled using older maven repository

I`m working on a project that compiles correctly but crashes on start when I set new maven repository on build.gradle file.
The project is using the lib holoeverywhere, and it crashes with the error: java.lang.NoClassDefFoundError: android.support.v4.app._HoloFragmentInflater$1
Until last month, everything was working fine, but suddenly the older company repository went offline and we created a new one. Now, if I set the older repository on my build.gradle file the app compiles and runs successfully, but if I remove the older repository, it still compiles but when I try to open it crash.
The main problem with that, is that new people trying to compile the code for the first time, using new or older repo, gets the crash on start.
So, I think this can be caused by some cache made by gradle, but looking at the .gradle folder I couldn't find anything.
Can some one help me with that?
Here is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url "http://<new_repository_url>/artifactory/simple/libs-release-local/"
}
// if I remove comment from these lines the project runs correctly
//maven {
//url "https://<old_repository_url>/content/groups/AndroidPublicRepository/"
//}
maven {
url "http://holoeverywhere.cf/repo"
}
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 131
versionName '1.5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE.txt'
}
android {
lintOptions {
abortOnError false
}
}
productFlavors {
}
}
configurations {
all*.exclude(group: 'org.springframework', module: 'spring-core')
all*.exclude(group: 'org.springframework', module: 'spring-web')
all*.exclude(group: 'org.hamcrest', module: 'hamcrest-core')
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:support-v13:19.1.0'
compile 'org.holoeverywhere:library:2.1.0'
compile 'com.viewpagerindicator:viewpagerindicator:2.4.1'
compile 'com.googlecode.libphonenumber:libphonenumber:5.9'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.4'
compile 'com.google.code.gson:gson:2.3'
compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-cache:1.4.14'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.14'
compile 'org.springframework.social:spring-social-core:1.0.2.PATCHED'
compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
exclude group: 'org.springframework.social', module: 'spring-social-core'
}
compile project(':addon-preferences-2.1.0')
}
I recommend you to remove HoloEverywhere from your app. It was a great library, but it isn't now. It's not very difficult: just change imports, some little adjustments and minSdkVersion = 15. Other option: Material Design.
Anyway, if you can't remove it or you can't do it right now:
HoloEverywhere had a dependency with a patched support-v4. I think the problem is that you don't have this patched version at your maven repository. You can find this code in the branch support-library.

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1

Here is the content of my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
credentials {
username artifactoryUserName
password artifactoryPassword
}
url 'http://test:8081/artifactory/libs-release-local'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
allprojects {
repositories {
maven {
credentials {
username artifactoryUserName
password artifactoryPassword
}
url 'http://test:8081/artifactory/libs-release-local'
}
mavenCentral()
maven { url 'http://repo1.maven.org/maven2' }
jcenter()
} }
Here is the content of app\build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "test.com"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
aseeConfig {
storeFile file("test.keystore")
storePassword "test123"
keyAlias "AndroidKey"
keyPassword "test123"
}
}
buildTypes {
release {
signingConfig signingConfigs.aseeConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
prod.initWith(buildTypes.release)
prod {
signingConfig signingConfigs.aseeConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
} }
dependencies {
//compile 'com.google.android:support-v4:r13'
compile 'com.google.android:google-play-services:4.1.32'
compile 'com.devsmart.android:devsmart-lib:1.0.0'
compile 'com.jeremyfeinstein.slidingmenu.lib:sliding-menu:1.0.0'
compile 'com.viewpagerindicator:viewpager-indicator:2.4.1'
///compile 'com.google.android.gms:google-play-services_lib:4.1.32'
compile 'com.emilsjolander:sticky-list-headers:1.0.0'
//compile 'com.actionbarsherlock:actionbar-sherlock:4.2.0'
compile 'com.mobeta.android.dslv:drag-sort-list-view:0.6.1'
compile 'com.threegvision.products:inigma_sdk_pro:3.24'
compile 'org.afree:a-free-chart:1.0.0'
compile 'org.afree:a-free-graphics:1.0.0'
compile 'net.simonvt:datepicker:1.0'
//compile 'eu.inmite:android-styled-dialogs:1.1'
compile 'com.nineoldandroids:nine-old-androids:2.4.1'
compile 'com.shinobicontrols.charts:shinobicharts:1.5.0-5'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.journeyapps:zxing-android-embedded:3.0.1#aar'
compile 'com.google.zxing:core:3.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/actionbarsherlock-4.2.0.jar')
compile files('libs/android-styled-dialogs-1.1.1-sources.jar')
compile files('libs/android-support-4.0.jar')
}
I can't build my project . I am getting this error:
I faced this kind of issue once but I don't remember exactly how to fix it.
As I rememeber, I follow this link
It's seem because there are many module dependent on difference support-v4 lib. So add multiDexEnabled true may works.
Also try to set all modules' dependency to a same version of support-v4. You can look at these link to known how to exclude compile v4 link1 link2 link3
If it still doesn't work, try to clean project, restart Studio, even restart your computer(I don't know why but this worked for me once)
Hope this helps.
in your build.gradle file set your compileSdkVersion 20.0.0 and buildToolsVersion "21.0.0"
Generally, it is because of resource conflicts within your modules.For sample, there are two ic_launcher.png in your app.(one from module and one from your app)
I searched to check resource conflicts but I didn't find official solution.
I only solved by this ways, remove each module and test it is being conflict or not. That's the simplest way to solve. I hope this will help you.
Here below are another suggestion....
I found also this way, one person(I didn't remember name) use safe delete to check conflict.
And some Q&A said, to add multiDexEnabled:true. That config is to increase dex file size. You can also use multidex support library .
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.
Here is the link for multiDex:
https://developer.android.com/tools/building/multidex.html
But documentation said you should be careful to use that.

NoClassDefFoundError using Jackson 2.2.x on Android with Gradle

For my Android project I set up Gradle with Jackson 2.2.x as follows:
// build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
}
I simply use the ObjectMapper here:
import com.fasterxml.jackson.databind.ObjectMapper;
// ...
ObjectMapper objectMapper = new ObjectMapper();
try {
Content content = objectMapper.readValue(inputStream, Content.class);
} catch (IOException e) {
e.printStackTrace();
}
When I run gradle installDebug and launch the relevant part of the application it crashes:
java.lang.NoClassDefFoundError: com.fasterxml.jackson.databind.ObjectMapper
Thoughts:
I noticed that in the error message com.fasterxml.jackson... is mentioned while com.fasterxml.jackson.core is defined in build.gradle. Is there a mismatch causing the problem?
I temporarily moved the dependencies block into the android block since I found other build.gradle configurations structured this way. However it seems to make no difference.
Gradle and Android don't always place nicely with dependencies(yet). Running
gradle clean
seems to fix most problems for me.
Note: If that didn't work, you can run
dexdump classes.dex | grep 'Class descriptor'
on the classes.dex file in the APK. That will check to see if the class is included in the classes.dex file. (Sometimes it's useful if you want to double check whats going on).
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.test"
minSdkVersion 9
targetSdkVersion 22
versionCode 4
versionName "1.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0' `enter code here`
compile 'com.fasterxml.jackson.core:jackson-databind :2.5.3'
}
Add permission and dependency into you Gradle and then build gradle you will get Object wrapper class

Categories

Resources