Currently I am using java 8 with latest android studio 2.1
Here is my build.gradle file
android {
compileSdkVersion 22
buildToolsVersion "24rc3"
defaultConfig {
applicationId "com.name"
minSdkVersion 10
targetSdkVersion 19
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
.......
}
I am getting the below compile time error that I have no clue
Error:com.android.jack.frontend.FrontendCompilationException: Failed
to compile at com.android.jack.Jack.buildSession(Jack.java:892) at
com.android.jack.Jack.run(Jack.java:472) at
com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:102)
... 8 more Warning:Exception while processing task
java.io.IOException: com.android.jack.api.v01.CompilationException:
Failed to compile :oTT:compileDebugJavaWithJack FAILED Error:Execution
failed for task ':oTT:compileDebugJavaWithJack'.
java.io.IOException: com.android.jack.api.v01.CompilationException: Failed to compile Information:BUILD FAILED
Please feel to ask if you need some details.
I had this error too, and what I found was that the error itself was masking another compilation issue. Look at your Console Messages carefully and see if there is something else not compiling. Once I solved the underlying issue with my own code, this error magically disappeared. Hope this helps.
Try to use next values:
compileSdkVersion = "android-N"
buildToolsVersion = "24.0.0 rc3"
you can try
compileSdkVersion 23
buildToolsVersion '24.0.0-rc3'
note the dash before rc3. This is according to http://developer.android.com/preview/setup-sdk.html under the section "Update an existing project"
I am using 23 just for the lambda.
the following link shows the Supported Java 8 Language Features and APIs https://developer.android.com/preview/j8-jack.html
I think we are all looking mostly at the same answer. To be precise I'd say "make sure the buildToolsVersion = "[version]" is the same as the [version] in the error".
For some this will be 24.0.0
Some java 8 features only support Android N. read android docs
http://developer.android.com/preview/j8-jack.html#configuration
When I use Default Methods on sdk23, I got this error too. so update your sdk version to Android N.
Related
The Android Studio 3.1 layout preview fails to find style 'coordinatorLayoutStyle' in the current theme.
Failed to instantiated one or more classes.
Exception shown are :-
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
This happened due to use of alpha version SDK 28
We need to change the android { ... } in "build.gradle" in app file
compileSdkVersion 28 to compileSdkVersion 27
targetSdkVersion 28 to targetSdkVersion 27
Also, try to change implementations like
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' to
implementation 'com.android.support:appcompat-v7:27.1.1'
Hope this works!
For Android Studio v3.1.*, in addition we need change:
implementation 'com.android.support:design:28.0.0-alpha3' to
implementation 'com.android.support:design:27.1.1'
you can fix this issue by adding this script to the app module build.gradle, in the android section
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.+"
}
}
}
}
This appears to be a bug in the current version of Android Studio (3.1.3) as I was encountering the same thing. I downloaded the beta build from here and opened my existing project and the errors disappeared.
https://developer.android.com/studio/preview/?utm_source=android-studio
Not exactly a fix but hopefully it will get you back up and running.
Update
1. com.android.support:appcompat stable version 28.0.0 is released. So no need to downgrade version. Just use 28.0.0.
def supportVersion = "28.0.0"
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
You can ignore design library if you don't need it.
2: You also need to update your compileSdkVersion & targetSdkVersion to remove some gradle warnings.
compileSdkVersion 28
targetSdkVersion 28
Never use alpha versions of any library, because alpha, beta and rc
versions may have bugs. And you don't want to face these types of errors often.
Important Suggestion
I suggest you migrate to androidx because android will not update support library after 28.0.0, all updates will be available to androidx package only. Check related answer.
This is fixed in Android Studio 3.2.
Go to app/res/styles and change the Theme.AppCompat.Light.DarkActionBar for this one Base.Theme.AppCompat.Light.DarkActionBar
Following on from another question, which is resolved.
I'm following through the Start Developing for Android course in Pluralsight. We're just about to add tests. The instructions say to add add androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' to the build.gradle file (the one in the app module).
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
applicationId 'com.sqisland.android.hello'
minSdkVersion 1
targetSdkVersion 24
versionCode 1
versionName '1.0.0'
}
dependencies {
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}
}
When I sync the build I can an error though:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage
Should I use the suggested fix? At the moment I'm thinking that's it's more likely that I'm missing a library somewhere.
After Andy's suggestion below
I've moved the block outside, the error is:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage
Move the dependencies block out of android block and raise your minSdkVersion to at least 8:
android {
minSdkVersion: 8
//...
}
dependencies {
// ....
}
I began to program with android and so I downloaded Android Studio 2.1.3 and android SDK and jdk 1.8.0_60 the Gradle version is 2.14.1.
I want to program with Android 2.2.
In my class called GameView is the problem:
bmp = BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_launcher);
it can not resolve symbol R
I read that I can solve the problem in these ways:
BUILD -> Clean Project
Tools -> Android -> Sync Project with Gradle Files
File -> Invalidate Caches / Restart
Nothing helped so I tried to changed the Versions in build.gradle(Module: app).
I do not really know wich Versions I need to program for Android 2.2.
Please help me or do you know any other solution to fix that problem?
Thanks!!!
In my case the solution was to put the minSdkVersion from 8 to 9.
I also changed the versions in build.gradle:
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.panjutorials.lazypudding"
minSdkVersion 9
targetSdkVersion 24
versionCode 1
versionName "1.0"
The only disadvantage is that I program with Android Nougat now but that's okay.
Good luck for everybody who has a similar problem.
I am trying to run an app that has a Google Maps Activity on my phone. My phone's running on Android 4.1.3 and the Minimum SDK for my project is API 15: Android 4.0.3
I just created the project on Android Studio and tried to run it on my phone. But it won't run and I am keep getting this error. Can someone tell me how to solve this?
That error probably means that you are using too much libraries. And because you are trying to use google maps I'm guessing you included everything google.
Try to just use the libraries you need.
For maps use this:
dependencies {
com.google.android.gms:play-services-maps:9.2.1
}
Reading material:
https://developers.google.com/android/guides/setup
You need to configure your gradle for multidex.
Modify the module-level build.gradle file configuration to include the support library and enable multidex output, as shown in the following code snippet:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
See more on same link which you are refering : https://developer.android.com/studio/build/multidex.html#mdex-gradle
You can also see some related question for same error:
How to enable multidexing with the new Android Multidex support library
Android java.exe finished with non-zero exit value 1
I'm confused with the compilation under Android.
I've a library using those dependencies :
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: 'httpclient'
}
//we need the org.apache.http.entity.ContentType class
compile('org.apache.httpcomponents:httpcore:4.3')
My misunderstanding is that it compiles and seems to run properly, but I would expect a compilation error since :
Android SDK contains many classes with exact same name as the classes in httpcore
Here are my questions :
Why is there no UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added:... during compilation ?
How can I know which version of the duplicate classes is used at runtime ?
I'm using build tools 19 :
buildToolsVersion "19.1.0"
compileSdkVersion 15
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
Use the official Apache HttpClient port for Android instead of the stock version